1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import {ChronoField} from './ChronoField';
|
8 | import {createTemporalQuery} from './TemporalQuery';
|
9 | import {TemporalQueries} from './TemporalQueries';
|
10 |
|
11 | import {LocalDate} from '../LocalDate';
|
12 | import {LocalTime} from '../LocalTime';
|
13 | import {ZoneOffset} from '../ZoneOffset';
|
14 |
|
15 |
|
16 | export function _init() {
|
17 |
|
18 | |
19 |
|
20 |
|
21 | TemporalQueries.ZONE_ID = createTemporalQuery('ZONE_ID', (temporal) => {
|
22 | return temporal.query(TemporalQueries.ZONE_ID);
|
23 | });
|
24 |
|
25 | |
26 |
|
27 |
|
28 | TemporalQueries.CHRONO = createTemporalQuery('CHRONO', (temporal) => {
|
29 | return temporal.query(TemporalQueries.CHRONO);
|
30 | });
|
31 |
|
32 | |
33 |
|
34 |
|
35 | TemporalQueries.PRECISION = createTemporalQuery('PRECISION', (temporal) => {
|
36 | return temporal.query(TemporalQueries.PRECISION);
|
37 | });
|
38 |
|
39 |
|
40 | |
41 |
|
42 |
|
43 | TemporalQueries.OFFSET = createTemporalQuery('OFFSET', (temporal) => {
|
44 | if (temporal.isSupported(ChronoField.OFFSET_SECONDS)) {
|
45 | return ZoneOffset.ofTotalSeconds(temporal.get(ChronoField.OFFSET_SECONDS));
|
46 | }
|
47 | return null;
|
48 | });
|
49 |
|
50 | |
51 |
|
52 |
|
53 | TemporalQueries.ZONE = createTemporalQuery('ZONE', (temporal) => {
|
54 | const zone = temporal.query(TemporalQueries.ZONE_ID);
|
55 | return (zone != null ? zone : temporal.query(TemporalQueries.OFFSET));
|
56 | });
|
57 |
|
58 | |
59 |
|
60 |
|
61 | TemporalQueries.LOCAL_DATE = createTemporalQuery('LOCAL_DATE', (temporal) => {
|
62 | if (temporal.isSupported(ChronoField.EPOCH_DAY)) {
|
63 | return LocalDate.ofEpochDay(temporal.getLong(ChronoField.EPOCH_DAY));
|
64 | }
|
65 | return null;
|
66 | });
|
67 |
|
68 | |
69 |
|
70 |
|
71 | TemporalQueries.LOCAL_TIME = createTemporalQuery('LOCAL_TIME', (temporal) => {
|
72 | if (temporal.isSupported(ChronoField.NANO_OF_DAY)) {
|
73 | return LocalTime.ofNanoOfDay(temporal.getLong(ChronoField.NANO_OF_DAY));
|
74 | }
|
75 | return null;
|
76 | });
|
77 | }
|