|
1 | 1 | import { ES } from './ecmascript.mjs';
|
2 | 2 | import { GetIntrinsic } from './intrinsicclass.mjs';
|
3 | 3 |
|
4 |
| -export const now = { |
5 |
| - instant, |
6 |
| - plainDateTime, |
7 |
| - plainDateTimeISO, |
8 |
| - plainDate, |
9 |
| - plainDateISO, |
10 |
| - plainTimeISO, |
11 |
| - timeZone, |
12 |
| - zonedDateTime, |
13 |
| - zonedDateTimeISO |
14 |
| -}; |
15 |
| - |
16 |
| -function instant() { |
| 4 | +const instant = () => { |
17 | 5 | const Instant = GetIntrinsic('%Temporal.Instant%');
|
18 | 6 | return new Instant(ES.SystemUTCEpochNanoSeconds());
|
19 |
| -} |
20 |
| -function plainDateTime(calendarLike, temporalTimeZoneLike = timeZone()) { |
| 7 | +}; |
| 8 | +const plainDateTime = (calendarLike, temporalTimeZoneLike = timeZone()) => { |
21 | 9 | const timeZone = ES.ToTemporalTimeZone(temporalTimeZoneLike);
|
22 | 10 | const calendar = ES.ToTemporalCalendar(calendarLike);
|
23 | 11 | const inst = instant();
|
24 | 12 | return ES.BuiltinTimeZoneGetPlainDateTimeFor(timeZone, inst, calendar);
|
25 |
| -} |
26 |
| -function plainDateTimeISO(temporalTimeZoneLike = timeZone()) { |
| 13 | +}; |
| 14 | +const plainDateTimeISO = (temporalTimeZoneLike = timeZone()) => { |
27 | 15 | const timeZone = ES.ToTemporalTimeZone(temporalTimeZoneLike);
|
28 | 16 | const calendar = ES.GetISO8601Calendar();
|
29 | 17 | const inst = instant();
|
30 | 18 | return ES.BuiltinTimeZoneGetPlainDateTimeFor(timeZone, inst, calendar);
|
31 |
| -} |
32 |
| -function zonedDateTime(calendarLike, temporalTimeZoneLike = timeZone()) { |
| 19 | +}; |
| 20 | +const zonedDateTime = (calendarLike, temporalTimeZoneLike = timeZone()) => { |
33 | 21 | const timeZone = ES.ToTemporalTimeZone(temporalTimeZoneLike);
|
34 | 22 | const calendar = ES.ToTemporalCalendar(calendarLike);
|
35 | 23 | return ES.CreateTemporalZonedDateTime(ES.SystemUTCEpochNanoSeconds(), timeZone, calendar);
|
36 |
| -} |
37 |
| -function zonedDateTimeISO(temporalTimeZoneLike = timeZone()) { |
| 24 | +}; |
| 25 | +const zonedDateTimeISO = (temporalTimeZoneLike = timeZone()) => { |
38 | 26 | return zonedDateTime(ES.GetISO8601Calendar(), temporalTimeZoneLike);
|
39 |
| -} |
40 |
| -function plainDate(calendarLike, temporalTimeZoneLike = timeZone()) { |
| 27 | +}; |
| 28 | +const plainDate = (calendarLike, temporalTimeZoneLike = timeZone()) => { |
41 | 29 | return ES.TemporalDateTimeToDate(plainDateTime(calendarLike, temporalTimeZoneLike));
|
42 |
| -} |
43 |
| -function plainDateISO(temporalTimeZoneLike = timeZone()) { |
| 30 | +}; |
| 31 | +const plainDateISO = (temporalTimeZoneLike = timeZone()) => { |
44 | 32 | return ES.TemporalDateTimeToDate(plainDateTimeISO(temporalTimeZoneLike));
|
45 |
| -} |
46 |
| -function plainTimeISO(temporalTimeZoneLike = timeZone()) { |
| 33 | +}; |
| 34 | +const plainTimeISO = (temporalTimeZoneLike = timeZone()) => { |
47 | 35 | return ES.TemporalDateTimeToTime(plainDateTimeISO(temporalTimeZoneLike));
|
48 |
| -} |
49 |
| -function timeZone() { |
| 36 | +}; |
| 37 | +const timeZone = () => { |
50 | 38 | return ES.SystemTimeZone();
|
51 |
| -} |
| 39 | +}; |
| 40 | + |
| 41 | +export const now = { |
| 42 | + instant, |
| 43 | + plainDateTime, |
| 44 | + plainDateTimeISO, |
| 45 | + plainDate, |
| 46 | + plainDateISO, |
| 47 | + plainTimeISO, |
| 48 | + timeZone, |
| 49 | + zonedDateTime, |
| 50 | + zonedDateTimeISO |
| 51 | +}; |
0 commit comments