temporal-polyfill-lite 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,831 +1,242 @@
1
- // original: https://github.com/tc39/proposal-temporal/blob/9291822b284e9b705ecf3d302a95d4f6d8517e0e/polyfill/index.d.ts
2
- /*! Copyright (c) 2017, 2018, 2019, 2020
3
- Ecma International. All rights reserved. */
4
- /*! SPDX-License-Identifier: BSD-3-Clause */
1
+ // original:
2
+ // - https://github.com/microsoft/TypeScript/blob/c9e7428bb76f0543a3555d0af87777e7db3a41e6/src/lib/esnext.temporal.d.ts
3
+ // - https://github.com/microsoft/TypeScript/blob/c9e7428bb76f0543a3555d0af87777e7db3a41e6/src/lib/esnext.intl.d.ts
4
+ /*! Copyright (c) Microsoft Corporation */
5
+ /*! SPDX-License-Identifier: Apache-2.0 */
5
6
 
6
7
  export namespace Temporal {
7
- export type ComparisonResult = -1 | 0 | 1;
8
- export type RoundingMode =
9
- | "ceil"
10
- | "floor"
11
- | "expand"
12
- | "trunc"
13
- | "halfCeil"
14
- | "halfFloor"
15
- | "halfExpand"
16
- | "halfTrunc"
17
- | "halfEven";
18
-
19
- /**
20
- * Options for assigning fields using `with()` or entire objects with
21
- * `from()`.
22
- * */
23
- export type AssignmentOptions = {
24
- /**
25
- * How to deal with out-of-range values
26
- *
27
- * - In `'constrain'` mode, out-of-range values are clamped to the nearest
28
- * in-range value.
29
- * - In `'reject'` mode, out-of-range values will cause the function to
30
- * throw a RangeError.
31
- *
32
- * The default is `'constrain'`.
33
- */
34
- overflow?: "constrain" | "reject" | undefined;
35
- };
36
-
37
- /**
38
- * Options for assigning fields using `Duration.prototype.with()` or entire
39
- * objects with `Duration.from()`, and for arithmetic with
40
- * `Duration.prototype.add()` and `Duration.prototype.subtract()`.
41
- * */
42
- export type DurationOptions = {
43
- /**
44
- * How to deal with out-of-range values
45
- *
46
- * - In `'constrain'` mode, out-of-range values are clamped to the nearest
47
- * in-range value.
48
- * - In `'balance'` mode, out-of-range values are resolved by balancing them
49
- * with the next highest unit.
50
- *
51
- * The default is `'constrain'`.
52
- */
53
- overflow?: "constrain" | "balance" | undefined;
54
- };
55
-
56
- /**
57
- * Options for conversions of `Temporal.PlainDateTime` to `Temporal.Instant`
58
- * */
59
- export type ToInstantOptions = {
60
- /**
61
- * Controls handling of invalid or ambiguous times caused by time zone
62
- * offset changes like Daylight Saving time (DST) transitions.
63
- *
64
- * This option is only relevant if a `DateTime` value does not exist in the
65
- * destination time zone (e.g. near "Spring Forward" DST transitions), or
66
- * exists more than once (e.g. near "Fall Back" DST transitions).
67
- *
68
- * In case of ambiguous or nonexistent times, this option controls what
69
- * exact time to return:
70
- * - `'compatible'`: Equivalent to `'earlier'` for backward transitions like
71
- * the start of DST in the Spring, and `'later'` for forward transitions
72
- * like the end of DST in the Fall. This matches the behavior of legacy
73
- * `Date`, of libraries like moment.js, Luxon, or date-fns, and of
74
- * cross-platform standards like [RFC 5545
75
- * (iCalendar)](https://tools.ietf.org/html/rfc5545).
76
- * - `'earlier'`: The earlier time of two possible times
77
- * - `'later'`: The later of two possible times
78
- * - `'reject'`: Throw a RangeError instead
79
- *
80
- * The default is `'compatible'`.
81
- *
82
- * */
83
- disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined;
84
- };
85
-
86
- type OffsetDisambiguationOptions = {
87
- /**
88
- * Time zone definitions can change. If an application stores data about
89
- * events in the future, then stored data about future events may become
90
- * ambiguous, for example if a country permanently abolishes DST. The
91
- * `offset` option controls this unusual case.
92
- *
93
- * - `'use'` always uses the offset (if it's provided) to calculate the
94
- * instant. This ensures that the result will match the instant that was
95
- * originally stored, even if local clock time is different.
96
- * - `'prefer'` uses the offset if it's valid for the date/time in this time
97
- * zone, but if it's not valid then the time zone will be used as a
98
- * fallback to calculate the instant.
99
- * - `'ignore'` will disregard any provided offset. Instead, the time zone
100
- * and date/time value are used to calculate the instant. This will keep
101
- * local clock time unchanged but may result in a different real-world
102
- * instant.
103
- * - `'reject'` acts like `'prefer'`, except it will throw a RangeError if
104
- * the offset is not valid for the given time zone identifier and
105
- * date/time value.
106
- *
107
- * If the ISO string ends in 'Z' then this option is ignored because there
108
- * is no possibility of ambiguity.
109
- *
110
- * If a time zone offset is not present in the input, then this option is
111
- * ignored because the time zone will always be used to calculate the
112
- * offset.
113
- *
114
- * If the offset is not used, and if the date/time and time zone don't
115
- * uniquely identify a single instant, then the `disambiguation` option will
116
- * be used to choose the correct instant. However, if the offset is used
117
- * then the `disambiguation` option will be ignored.
118
- */
119
- offset?: "use" | "prefer" | "ignore" | "reject" | undefined;
120
- };
121
-
122
- export type ZonedDateTimeAssignmentOptions = AssignmentOptions &
123
- ToInstantOptions &
124
- OffsetDisambiguationOptions;
125
-
126
- /**
127
- * Options for arithmetic operations like `add()` and `subtract()`
128
- * */
129
- export type ArithmeticOptions = {
130
- /**
131
- * Controls handling of out-of-range arithmetic results.
132
- *
133
- * If a result is out of range, then `'constrain'` will clamp the result to
134
- * the allowed range, while `'reject'` will throw a RangeError.
135
- *
136
- * The default is `'constrain'`.
137
- */
138
- overflow?: "constrain" | "reject" | undefined;
139
- };
140
-
141
- export type DateUnit = "year" | "month" | "week" | "day";
142
- export type TimeUnit =
143
- | "hour"
144
- | "minute"
145
- | "second"
146
- | "millisecond"
147
- | "microsecond"
148
- | "nanosecond";
149
- export type DateTimeUnit = DateUnit | TimeUnit;
150
-
151
- /**
152
- * When the name of a unit is provided to a Temporal API as a string, it is
153
- * usually singular, e.g. 'day' or 'hour'. But plural unit names like 'days'
154
- * or 'hours' are also accepted.
155
- * */
156
- export type PluralUnit<T extends DateTimeUnit> = {
157
- year: "years";
158
- month: "months";
159
- week: "weeks";
160
- day: "days";
161
- hour: "hours";
162
- minute: "minutes";
163
- second: "seconds";
164
- millisecond: "milliseconds";
165
- microsecond: "microseconds";
166
- nanosecond: "nanoseconds";
167
- }[T];
168
-
169
- export type LargestUnit<T extends DateTimeUnit> = "auto" | T | PluralUnit<T>;
170
- export type SmallestUnit<T extends DateTimeUnit> = T | PluralUnit<T>;
171
- export type TotalUnit<T extends DateTimeUnit> = T | PluralUnit<T>;
172
-
173
- /**
174
- * Options for outputting precision in toString() on types with seconds
175
- */
176
- export type ToStringPrecisionOptions = {
177
- fractionalSecondDigits?: "auto" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
178
- smallestUnit?:
179
- | SmallestUnit<"minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
180
- | undefined;
181
-
182
- /**
183
- * Controls how rounding is performed:
184
- * - `halfExpand`: Round to the nearest of the values allowed by
185
- * `roundingIncrement` and `smallestUnit`. When there is a tie, round up.
186
- * This mode is the default.
187
- * - `ceil`: Always round up, towards the end of time.
188
- * - `trunc`: Always round down, towards the beginning of time.
189
- * - `floor`: Also round down, towards the beginning of time. This mode acts
190
- * the same as `trunc`, but it's included for consistency with
191
- * `Temporal.Duration.round()` where negative values are allowed and
192
- * `trunc` rounds towards zero, unlike `floor` which rounds towards
193
- * negative infinity which is usually unexpected. For this reason, `trunc`
194
- * is recommended for most use cases.
195
- */
196
- roundingMode?: RoundingMode | undefined;
197
- };
198
-
199
- export type ShowCalendarOption = {
200
- calendarName?: "auto" | "always" | "never" | "critical" | undefined;
8
+ type CalendarLike =
9
+ | PlainDate
10
+ | PlainDateTime
11
+ | PlainMonthDay
12
+ | PlainYearMonth
13
+ | ZonedDateTime
14
+ | string;
15
+ type DurationLike = Duration | DurationLikeObject | string;
16
+ type InstantLike = Instant | ZonedDateTime | string;
17
+ type PlainDateLike = PlainDate | ZonedDateTime | PlainDateTime | DateLikeObject | string;
18
+ type PlainDateTimeLike = PlainDateTime | ZonedDateTime | PlainDate | DateTimeLikeObject | string;
19
+ type PlainMonthDayLike = PlainMonthDay | DateLikeObject | string;
20
+ type PlainTimeLike = PlainTime | PlainDateTime | ZonedDateTime | TimeLikeObject | string;
21
+ type PlainYearMonthLike = PlainYearMonth | YearMonthLikeObject | string;
22
+ type TimeZoneLike = ZonedDateTime | string;
23
+ type ZonedDateTimeLike = ZonedDateTime | ZonedDateTimeLikeObject | string;
24
+
25
+ type PartialTemporalLike<T extends object> = {
26
+ [P in Exclude<keyof T, "calendar" | "timeZone">]?: T[P] | undefined;
201
27
  };
202
28
 
203
- export type CalendarTypeToStringOptions = ToStringPrecisionOptions & ShowCalendarOption;
204
-
205
- export type ZonedDateTimeToStringOptions = CalendarTypeToStringOptions & {
206
- timeZoneName?: "auto" | "never" | "critical" | undefined;
207
- offset?: "auto" | "never" | undefined;
208
- };
29
+ interface DateLikeObject {
30
+ year?: number | undefined;
31
+ era?: string | undefined;
32
+ eraYear?: number | undefined;
33
+ month?: number | undefined;
34
+ monthCode?: string | undefined;
35
+ day: number;
36
+ calendar?: string | undefined;
37
+ }
209
38
 
210
- export type InstantToStringOptions = ToStringPrecisionOptions & {
211
- timeZone?: TimeZoneLike | undefined;
212
- };
39
+ interface DateTimeLikeObject extends DateLikeObject, TimeLikeObject {}
213
40
 
214
- /**
215
- * Options to control the result of `until()` and `since()` methods in
216
- * `Temporal` types.
217
- */
218
- export interface DifferenceOptions<T extends DateTimeUnit> {
219
- /**
220
- * The unit to round to. For example, to round to the nearest minute, use
221
- * `smallestUnit: 'minute'`. This property is optional for `until()` and
222
- * `since()`, because those methods default behavior is not to round.
223
- * However, the same property is required for `round()`.
224
- */
225
- smallestUnit?: SmallestUnit<T> | undefined;
41
+ interface DurationLikeObject {
42
+ years?: number | undefined;
43
+ months?: number | undefined;
44
+ weeks?: number | undefined;
45
+ days?: number | undefined;
46
+ hours?: number | undefined;
47
+ minutes?: number | undefined;
48
+ seconds?: number | undefined;
49
+ milliseconds?: number | undefined;
50
+ microseconds?: number | undefined;
51
+ nanoseconds?: number | undefined;
52
+ }
226
53
 
227
- /**
228
- * The largest unit to allow in the resulting `Temporal.Duration` object.
229
- *
230
- * Larger units will be "balanced" into smaller units. For example, if
231
- * `largestUnit` is `'minute'` then a two-hour duration will be output as a
232
- * 120-minute duration.
233
- *
234
- * Valid values may include `'year'`, `'month'`, `'week'`, `'day'`,
235
- * `'hour'`, `'minute'`, `'second'`, `'millisecond'`, `'microsecond'`,
236
- * `'nanosecond'` and `'auto'`, although some types may throw an exception
237
- * if a value is used that would produce an invalid result. For example,
238
- * `hours` is not accepted by `Temporal.PlainDate.prototype.since()`.
239
- *
240
- * The default is always `'auto'`, though the meaning of this depends on the
241
- * type being used.
242
- */
243
- largestUnit?: LargestUnit<T> | undefined;
54
+ interface TimeLikeObject {
55
+ hour?: number | undefined;
56
+ minute?: number | undefined;
57
+ second?: number | undefined;
58
+ millisecond?: number | undefined;
59
+ microsecond?: number | undefined;
60
+ nanosecond?: number | undefined;
61
+ }
244
62
 
245
- /**
246
- * Allows rounding to an integer number of units. For example, to round to
247
- * increments of a half hour, use `{ smallestUnit: 'minute',
248
- * roundingIncrement: 30 }`.
249
- */
250
- roundingIncrement?: number | undefined;
63
+ interface YearMonthLikeObject extends Omit<DateLikeObject, "day"> {}
251
64
 
252
- /**
253
- * Controls how rounding is performed:
254
- * - `halfExpand`: Round to the nearest of the values allowed by
255
- * `roundingIncrement` and `smallestUnit`. When there is a tie, round away
256
- * from zero like `ceil` for positive durations and like `floor` for
257
- * negative durations.
258
- * - `ceil`: Always round up, towards the end of time.
259
- * - `trunc`: Always round down, towards the beginning of time. This mode is
260
- * the default.
261
- * - `floor`: Also round down, towards the beginning of time. This mode acts
262
- * the same as `trunc`, but it's included for consistency with
263
- * `Temporal.Duration.round()` where negative values are allowed and
264
- * `trunc` rounds towards zero, unlike `floor` which rounds towards
265
- * negative infinity which is usually unexpected. For this reason, `trunc`
266
- * is recommended for most use cases.
267
- */
268
- roundingMode?: RoundingMode | undefined;
65
+ interface ZonedDateTimeLikeObject extends DateTimeLikeObject {
66
+ timeZone: TimeZoneLike;
67
+ offset?: string | undefined;
269
68
  }
270
69
 
271
- /**
272
- * `round` methods take one required parameter. If a string is provided, the
273
- * resulting `Temporal.Duration` object will be rounded to that unit. If an
274
- * object is provided, its `smallestUnit` property is required while other
275
- * properties are optional. A string is treated the same as an object whose
276
- * `smallestUnit` property value is that string.
277
- */
278
- export type RoundTo<T extends DateTimeUnit> =
279
- | SmallestUnit<T>
70
+ type DateUnit = "year" | "month" | "week" | "day";
71
+ type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond";
72
+ type PluralizeUnit<T extends DateUnit | TimeUnit> =
73
+ | T
280
74
  | {
281
- /**
282
- * The unit to round to. For example, to round to the nearest minute,
283
- * use `smallestUnit: 'minute'`. This option is required. Note that the
284
- * same-named property is optional when passed to `until` or `since`
285
- * methods, because those methods do no rounding by default.
286
- */
287
- smallestUnit: SmallestUnit<T>;
288
-
289
- /**
290
- * Allows rounding to an integer number of units. For example, to round to
291
- * increments of a half hour, use `{ smallestUnit: 'minute',
292
- * roundingIncrement: 30 }`.
293
- */
294
- roundingIncrement?: number | undefined;
295
-
296
- /**
297
- * Controls how rounding is performed:
298
- * - `halfExpand`: Round to the nearest of the values allowed by
299
- * `roundingIncrement` and `smallestUnit`. When there is a tie, round up.
300
- * This mode is the default.
301
- * - `ceil`: Always round up, towards the end of time.
302
- * - `trunc`: Always round down, towards the beginning of time.
303
- * - `floor`: Also round down, towards the beginning of time. This mode acts
304
- * the same as `trunc`, but it's included for consistency with
305
- * `Temporal.Duration.round()` where negative values are allowed and
306
- * `trunc` rounds towards zero, unlike `floor` which rounds towards
307
- * negative infinity which is usually unexpected. For this reason, `trunc`
308
- * is recommended for most use cases.
309
- */
310
- roundingMode?: RoundingMode | undefined;
311
- };
312
-
313
- /**
314
- * The `round` method of the `Temporal.Duration` accepts one required
315
- * parameter. If a string is provided, the resulting `Temporal.Duration`
316
- * object will be rounded to that unit. If an object is provided, the
317
- * `smallestUnit` and/or `largestUnit` property is required, while other
318
- * properties are optional. A string parameter is treated the same as an
319
- * object whose `smallestUnit` property value is that string.
320
- */
321
- export type DurationRoundTo =
322
- | SmallestUnit<DateTimeUnit>
323
- | ((
324
- | {
325
- /**
326
- * The unit to round to. For example, to round to the nearest
327
- * minute, use `smallestUnit: 'minute'`. This property is normally
328
- * required, but is optional if `largestUnit` is provided and not
329
- * undefined.
330
- */
331
- smallestUnit: SmallestUnit<DateTimeUnit>;
332
-
333
- /**
334
- * The largest unit to allow in the resulting `Temporal.Duration`
335
- * object.
336
- *
337
- * Larger units will be "balanced" into smaller units. For example,
338
- * if `largestUnit` is `'minute'` then a two-hour duration will be
339
- * output as a 120-minute duration.
340
- *
341
- * Valid values include `'year'`, `'month'`, `'week'`, `'day'`,
342
- * `'hour'`, `'minute'`, `'second'`, `'millisecond'`,
343
- * `'microsecond'`, `'nanosecond'` and `'auto'`.
344
- *
345
- * The default is `'auto'`, which means "the largest nonzero unit in
346
- * the input duration". This default prevents expanding durations to
347
- * larger units unless the caller opts into this behavior.
348
- *
349
- * If `smallestUnit` is larger, then `smallestUnit` will be used as
350
- * `largestUnit`, superseding a caller-supplied or default value.
351
- */
352
- largestUnit?: LargestUnit<DateTimeUnit> | undefined;
353
- }
354
- | {
355
- /**
356
- * The unit to round to. For example, to round to the nearest
357
- * minute, use `smallestUnit: 'minute'`. This property is normally
358
- * required, but is optional if `largestUnit` is provided and not
359
- * undefined.
360
- */
361
- smallestUnit?: SmallestUnit<DateTimeUnit> | undefined;
362
-
363
- /**
364
- * The largest unit to allow in the resulting `Temporal.Duration`
365
- * object.
366
- *
367
- * Larger units will be "balanced" into smaller units. For example,
368
- * if `largestUnit` is `'minute'` then a two-hour duration will be
369
- * output as a 120-minute duration.
370
- *
371
- * Valid values include `'year'`, `'month'`, `'week'`, `'day'`,
372
- * `'hour'`, `'minute'`, `'second'`, `'millisecond'`,
373
- * `'microsecond'`, `'nanosecond'` and `'auto'`.
374
- *
375
- * The default is `'auto'`, which means "the largest nonzero unit in
376
- * the input duration". This default prevents expanding durations to
377
- * larger units unless the caller opts into this behavior.
378
- *
379
- * If `smallestUnit` is larger, then `smallestUnit` will be used as
380
- * `largestUnit`, superseding a caller-supplied or default value.
381
- */
382
- largestUnit: LargestUnit<DateTimeUnit>;
383
- }
384
- ) & {
385
- /**
386
- * Allows rounding to an integer number of units. For example, to round
387
- * to increments of a half hour, use `{ smallestUnit: 'minute',
388
- * roundingIncrement: 30 }`.
389
- */
390
- roundingIncrement?: number | undefined;
391
-
392
- /**
393
- * Controls how rounding is performed:
394
- * - `halfExpand`: Round to the nearest of the values allowed by
395
- * `roundingIncrement` and `smallestUnit`. When there is a tie, round
396
- * away from zero like `ceil` for positive durations and like `floor`
397
- * for negative durations. This mode is the default.
398
- * - `ceil`: Always round towards positive infinity. For negative
399
- * durations this option will decrease the absolute value of the
400
- * duration which may be unexpected. To round away from zero, use
401
- * `ceil` for positive durations and `floor` for negative durations.
402
- * - `trunc`: Always round down towards zero.
403
- * - `floor`: Always round towards negative infinity. This mode acts the
404
- * same as `trunc` for positive durations but for negative durations
405
- * it will increase the absolute value of the result which may be
406
- * unexpected. For this reason, `trunc` is recommended for most "round
407
- * down" use cases.
408
- */
409
- roundingMode?: RoundingMode | undefined;
410
-
411
- /**
412
- * The starting point to use for rounding and conversions when
413
- * variable-length units (years, months, weeks depending on the
414
- * calendar) are involved. This option is required if any of the
415
- * following are true:
416
- * - `unit` is `'week'` or larger units
417
- * - `this` has a nonzero value for `weeks` or larger units
418
- *
419
- * This value must be either a `Temporal.PlainDateTime`, a
420
- * `Temporal.ZonedDateTime`, or a string or object value that can be
421
- * passed to `from()` of those types. Examples:
422
- * - `'2020-01-01T00:00-08:00[America/Los_Angeles]'`
423
- * - `'2020-01-01'`
424
- * - `Temporal.PlainDate.from('2020-01-01')`
425
- *
426
- * `Temporal.ZonedDateTime` will be tried first because it's more
427
- * specific, with `Temporal.PlainDateTime` as a fallback.
428
- *
429
- * If the value resolves to a `Temporal.ZonedDateTime`, then operation
430
- * will adjust for DST and other time zone transitions. Otherwise
431
- * (including if this option is omitted), then the operation will ignore
432
- * time zone transitions and all days will be assumed to be 24 hours
433
- * long.
434
- */
435
- relativeTo?:
436
- | Temporal.PlainDateTime
437
- | Temporal.ZonedDateTime
438
- | PlainDateTimeLike
439
- | ZonedDateTimeLike
440
- | string
441
- | undefined;
442
- });
75
+ year: "years";
76
+ month: "months";
77
+ week: "weeks";
78
+ day: "days";
79
+ hour: "hours";
80
+ minute: "minutes";
81
+ second: "seconds";
82
+ millisecond: "milliseconds";
83
+ microsecond: "microseconds";
84
+ nanosecond: "nanoseconds";
85
+ }[T];
86
+
87
+ interface DisambiguationOptions {
88
+ disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined;
89
+ }
443
90
 
444
- /**
445
- * Options to control behavior of `Duration.prototype.total()`
446
- */
447
- export type DurationTotalOf =
448
- | TotalUnit<DateTimeUnit>
449
- | {
450
- /**
451
- * The unit to convert the duration to. This option is required.
452
- */
453
- unit: TotalUnit<DateTimeUnit>;
91
+ interface OverflowOptions {
92
+ overflow?: "constrain" | "reject" | undefined;
93
+ }
454
94
 
455
- /**
456
- * The starting point to use when variable-length units (years, months,
457
- * weeks depending on the calendar) are involved. This option is required if
458
- * any of the following are true:
459
- * - `unit` is `'week'` or larger units
460
- * - `this` has a nonzero value for `weeks` or larger units
461
- *
462
- * This value must be either a `Temporal.PlainDateTime`, a
463
- * `Temporal.ZonedDateTime`, or a string or object value that can be passed
464
- * to `from()` of those types. Examples:
465
- * - `'2020-01-01T00:00-08:00[America/Los_Angeles]'`
466
- * - `'2020-01-01'`
467
- * - `Temporal.PlainDate.from('2020-01-01')`
468
- *
469
- * `Temporal.ZonedDateTime` will be tried first because it's more
470
- * specific, with `Temporal.PlainDateTime` as a fallback.
471
- *
472
- * If the value resolves to a `Temporal.ZonedDateTime`, then operation will
473
- * adjust for DST and other time zone transitions. Otherwise (including if
474
- * this option is omitted), then the operation will ignore time zone
475
- * transitions and all days will be assumed to be 24 hours long.
476
- */
477
- relativeTo?:
478
- | Temporal.ZonedDateTime
479
- | Temporal.PlainDateTime
480
- | ZonedDateTimeLike
481
- | PlainDateTimeLike
482
- | string
483
- | undefined;
484
- };
95
+ interface TransitionOptions {
96
+ direction: "next" | "previous";
97
+ }
485
98
 
486
- /**
487
- * Options to control behavior of `Duration.compare()`
488
- */
489
- export interface DurationArithmeticOptions {
490
- /**
491
- * The starting point to use when variable-length units (years, months,
492
- * weeks depending on the calendar) are involved. This option is required if
493
- * either of the durations has a nonzero value for `weeks` or larger units.
494
- *
495
- * This value must be either a `Temporal.PlainDateTime`, a
496
- * `Temporal.ZonedDateTime`, or a string or object value that can be passed
497
- * to `from()` of those types. Examples:
498
- * - `'2020-01-01T00:00-08:00[America/Los_Angeles]'`
499
- * - `'2020-01-01'`
500
- * - `Temporal.PlainDate.from('2020-01-01')`
501
- *
502
- * `Temporal.ZonedDateTime` will be tried first because it's more
503
- * specific, with `Temporal.PlainDateTime` as a fallback.
504
- *
505
- * If the value resolves to a `Temporal.ZonedDateTime`, then operation will
506
- * adjust for DST and other time zone transitions. Otherwise (including if
507
- * this option is omitted), then the operation will ignore time zone
508
- * transitions and all days will be assumed to be 24 hours long.
509
- */
510
- relativeTo?:
511
- | Temporal.ZonedDateTime
512
- | Temporal.PlainDateTime
513
- | ZonedDateTimeLike
514
- | PlainDateTimeLike
515
- | string
99
+ interface RoundingOptions<Units extends DateUnit | TimeUnit> {
100
+ smallestUnit?: PluralizeUnit<Units> | undefined;
101
+ roundingIncrement?: number | undefined;
102
+ roundingMode?:
103
+ | "ceil"
104
+ | "floor"
105
+ | "expand"
106
+ | "trunc"
107
+ | "halfCeil"
108
+ | "halfFloor"
109
+ | "halfExpand"
110
+ | "halfTrunc"
111
+ | "halfEven"
516
112
  | undefined;
517
113
  }
518
114
 
519
- /**
520
- * Options to control behaviour of `ZonedDateTime.prototype.getTimeZoneTransition()`
521
- */
522
- export type TransitionDirection = "next" | "previous" | { direction: "next" | "previous" };
523
-
524
- export type DurationLike = {
525
- years?: number | undefined;
526
- months?: number | undefined;
527
- weeks?: number | undefined;
528
- days?: number | undefined;
529
- hours?: number | undefined;
530
- minutes?: number | undefined;
531
- seconds?: number | undefined;
532
- milliseconds?: number | undefined;
533
- microseconds?: number | undefined;
534
- nanoseconds?: number | undefined;
535
- };
115
+ interface RoundingOptionsWithLargestUnit<
116
+ Units extends DateUnit | TimeUnit,
117
+ > extends RoundingOptions<Units> {
118
+ largestUnit?: "auto" | PluralizeUnit<Units> | undefined;
119
+ }
536
120
 
537
- /**
538
- * Options for Intl.DurationFormat
539
- */
540
- export type DurationFormatOptions = {
541
- localeMatcher?: "lookup" | "best fit" | undefined;
542
- numberingSystem?: string | undefined;
543
- style?: "long" | "short" | "narrow" | "digital" | undefined;
544
- years?: "long" | "short" | "narrow" | undefined;
545
- yearsDisplay?: "always" | "auto" | undefined;
546
- months?: "long" | "short" | "narrow" | undefined;
547
- monthsDisplay?: "always" | "auto" | undefined;
548
- weeks?: "long" | "short" | "narrow" | undefined;
549
- weeksDisplay?: "always" | "auto" | undefined;
550
- days?: "long" | "short" | "narrow" | undefined;
551
- daysDisplay?: "always" | "auto" | undefined;
552
- hours?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined;
553
- hoursDisplay?: "always" | "auto" | undefined;
554
- minutes?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined;
555
- minutesDisplay?: "always" | "auto" | undefined;
556
- seconds?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined;
557
- secondsDisplay?: "always" | "auto" | undefined;
558
- milliseconds?: "long" | "short" | "narrow" | "numeric" | undefined;
559
- millisecondsDisplay?: "always" | "auto" | undefined;
560
- microseconds?: "long" | "short" | "narrow" | "numeric" | undefined;
561
- microsecondsDisplay?: "always" | "auto" | undefined;
562
- nanoseconds?: "long" | "short" | "narrow" | "numeric" | undefined;
563
- nanosecondsDisplay?: "always" | "auto" | undefined;
564
- fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
565
- };
121
+ interface ToStringRoundingOptions<Units extends DateUnit | TimeUnit> extends Pick<
122
+ RoundingOptions<Units>,
123
+ "smallestUnit" | "roundingMode"
124
+ > {}
566
125
 
567
- /**
568
- *
569
- * A `Temporal.Duration` represents an immutable duration of time which can be
570
- * used in date/time arithmetic.
571
- *
572
- * See https://tc39.es/proposal-temporal/docs/duration.html for more details.
573
- */
574
- export class Duration {
575
- static from(item: Temporal.Duration | DurationLike | string): Temporal.Duration;
576
- static compare(
577
- one: Temporal.Duration | DurationLike | string,
578
- two: Temporal.Duration | DurationLike | string,
579
- options?: DurationArithmeticOptions,
580
- ): ComparisonResult;
581
- constructor(
582
- years?: number,
583
- months?: number,
584
- weeks?: number,
585
- days?: number,
586
- hours?: number,
587
- minutes?: number,
588
- seconds?: number,
589
- milliseconds?: number,
590
- microseconds?: number,
591
- nanoseconds?: number,
592
- );
593
- readonly sign: -1 | 0 | 1;
594
- readonly blank: boolean;
595
- readonly years: number;
596
- readonly months: number;
597
- readonly weeks: number;
598
- readonly days: number;
599
- readonly hours: number;
600
- readonly minutes: number;
601
- readonly seconds: number;
602
- readonly milliseconds: number;
603
- readonly microseconds: number;
604
- readonly nanoseconds: number;
605
- negated(): Temporal.Duration;
606
- abs(): Temporal.Duration;
607
- with(durationLike: DurationLike): Temporal.Duration;
608
- add(other: Temporal.Duration | DurationLike | string): Temporal.Duration;
609
- subtract(other: Temporal.Duration | DurationLike | string): Temporal.Duration;
610
- round(roundTo: DurationRoundTo): Temporal.Duration;
611
- total(totalOf: DurationTotalOf): number;
612
- toLocaleString(
613
- locales?: globalThis.Intl.LocalesArgument,
614
- options?: DurationFormatOptions,
615
- ): string;
616
- toJSON(): string;
617
- toString(options?: ToStringPrecisionOptions): string;
618
- valueOf(): never;
619
- readonly [Symbol.toStringTag]: "Temporal.Duration";
126
+ interface ToStringRoundingOptionsWithFractionalSeconds<
127
+ Units extends DateUnit | TimeUnit,
128
+ > extends ToStringRoundingOptions<Units> {
129
+ fractionalSecondDigits?: "auto" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
620
130
  }
621
131
 
622
- /**
623
- * A `Temporal.Instant` is an exact point in time, with a precision in
624
- * nanoseconds. No time zone or calendar information is present. Therefore,
625
- * `Temporal.Instant` has no concept of days, months, or even hours.
626
- *
627
- * For convenience of interoperability, it internally uses nanoseconds since
628
- * the {@link https://en.wikipedia.org/wiki/Unix_time|Unix epoch} (midnight
629
- * UTC on January 1, 1970). However, a `Temporal.Instant` can be created from
630
- * any of several expressions that refer to a single point in time, including
631
- * an {@link https://datatracker.ietf.org/doc/html/rfc9557|RFC 9557 string}
632
- * with a time zone offset such as '2020-01-23T17:04:36.491865121-08:00'.
633
- *
634
- * See https://tc39.es/proposal-temporal/docs/instant.html for more details.
635
- */
636
- export class Instant {
637
- static fromEpochMilliseconds(epochMilliseconds: number): Temporal.Instant;
638
- static fromEpochNanoseconds(epochNanoseconds: bigint): Temporal.Instant;
639
- static from(item: Temporal.Instant | string): Temporal.Instant;
640
- static compare(
641
- one: Temporal.Instant | string,
642
- two: Temporal.Instant | string,
643
- ): ComparisonResult;
644
- constructor(epochNanoseconds: bigint);
645
- readonly epochMilliseconds: number;
646
- readonly epochNanoseconds: bigint;
647
- equals(other: Temporal.Instant | string): boolean;
648
- add(
649
- durationLike:
650
- | Omit<Temporal.Duration | DurationLike, "years" | "months" | "weeks" | "days">
651
- | string,
652
- ): Temporal.Instant;
653
- subtract(
654
- durationLike:
655
- | Omit<Temporal.Duration | DurationLike, "years" | "months" | "weeks" | "days">
656
- | string,
657
- ): Temporal.Instant;
658
- until(
659
- other: Temporal.Instant | string,
660
- options?: DifferenceOptions<
661
- "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
662
- >,
663
- ): Temporal.Duration;
664
- since(
665
- other: Temporal.Instant | string,
666
- options?: DifferenceOptions<
667
- "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
668
- >,
669
- ): Temporal.Duration;
670
- round(
671
- roundTo: RoundTo<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">,
672
- ): Temporal.Instant;
673
- toZonedDateTimeISO(tzLike: TimeZoneLike): Temporal.ZonedDateTime;
674
- toLocaleString(
675
- locales?: globalThis.Intl.LocalesArgument,
676
- options?: globalThis.Intl.DateTimeFormatOptions,
677
- ): string;
678
- toJSON(): string;
679
- toString(options?: InstantToStringOptions): string;
680
- valueOf(): never;
681
- readonly [Symbol.toStringTag]: "Temporal.Instant";
132
+ namespace Now {
133
+ function timeZoneId(): string;
134
+ function instant(): Instant;
135
+ function plainDateTimeISO(timeZone?: TimeZoneLike): PlainDateTime;
136
+ function zonedDateTimeISO(timeZone?: TimeZoneLike): ZonedDateTime;
137
+ function plainDateISO(timeZone?: TimeZoneLike): PlainDate;
138
+ function plainTimeISO(timeZone?: TimeZoneLike): PlainTime;
682
139
  }
683
140
 
684
- /**
685
- * Any of these types can be passed to Temporal methods instead of a calendar ID.
686
- * */
687
- export type CalendarLike =
688
- | string
689
- | ZonedDateTime
690
- | PlainDateTime
691
- | PlainDate
692
- | PlainYearMonth
693
- | PlainMonthDay;
141
+ interface PlainDateToStringOptions {
142
+ calendarName?: "auto" | "always" | "never" | "critical" | undefined;
143
+ }
694
144
 
695
- export type PlainDateLike = {
696
- era?: string | undefined;
697
- eraYear?: number | undefined;
698
- year?: number | undefined;
699
- month?: number | undefined;
700
- monthCode?: string | undefined;
701
- day?: number | undefined;
702
- calendar?: CalendarLike | undefined;
703
- };
145
+ interface PlainDateToZonedDateTimeOptions {
146
+ plainTime?: PlainTimeLike | undefined;
147
+ timeZone: TimeZoneLike;
148
+ }
704
149
 
705
- /**
706
- * A `Temporal.PlainDate` represents a calendar date. "Calendar date" refers to the
707
- * concept of a date as expressed in everyday usage, independent of any time
708
- * zone. For example, it could be used to represent an event on a calendar
709
- * which happens during the whole day no matter which time zone it's happening
710
- * in.
711
- *
712
- * See https://tc39.es/proposal-temporal/docs/date.html for more details.
713
- */
714
- export class PlainDate {
715
- static from(
716
- item: Temporal.PlainDate | PlainDateLike | string,
717
- options?: AssignmentOptions,
718
- ): Temporal.PlainDate;
719
- static compare(
720
- one: Temporal.PlainDate | PlainDateLike | string,
721
- two: Temporal.PlainDate | PlainDateLike | string,
722
- ): ComparisonResult;
723
- constructor(isoYear: number, isoMonth: number, isoDay: number, calendar?: string);
150
+ interface PlainDate {
151
+ readonly calendarId: string;
724
152
  readonly era: string | undefined;
725
153
  readonly eraYear: number | undefined;
726
154
  readonly year: number;
727
155
  readonly month: number;
728
156
  readonly monthCode: string;
729
157
  readonly day: number;
730
- readonly calendarId: string;
731
158
  readonly dayOfWeek: number;
732
159
  readonly dayOfYear: number;
733
160
  readonly weekOfYear: number | undefined;
734
161
  readonly yearOfWeek: number | undefined;
735
162
  readonly daysInWeek: number;
736
- readonly daysInYear: number;
737
163
  readonly daysInMonth: number;
164
+ readonly daysInYear: number;
738
165
  readonly monthsInYear: number;
739
166
  readonly inLeapYear: boolean;
740
- equals(other: Temporal.PlainDate | PlainDateLike | string): boolean;
741
- with(dateLike: PlainDateLike, options?: AssignmentOptions): Temporal.PlainDate;
742
- withCalendar(calendar: CalendarLike): Temporal.PlainDate;
743
- add(
744
- durationLike: Temporal.Duration | DurationLike | string,
745
- options?: ArithmeticOptions,
746
- ): Temporal.PlainDate;
747
- subtract(
748
- durationLike: Temporal.Duration | DurationLike | string,
749
- options?: ArithmeticOptions,
750
- ): Temporal.PlainDate;
751
- until(
752
- other: Temporal.PlainDate | PlainDateLike | string,
753
- options?: DifferenceOptions<"year" | "month" | "week" | "day">,
754
- ): Temporal.Duration;
755
- since(
756
- other: Temporal.PlainDate | PlainDateLike | string,
757
- options?: DifferenceOptions<"year" | "month" | "week" | "day">,
758
- ): Temporal.Duration;
759
- toPlainDateTime(
760
- temporalTime?: Temporal.PlainTime | PlainTimeLike | string,
761
- ): Temporal.PlainDateTime;
762
- toZonedDateTime(
763
- timeZoneAndTime:
764
- | string
765
- | {
766
- timeZone: TimeZoneLike;
767
- plainTime?: Temporal.PlainTime | PlainTimeLike | string | undefined;
768
- },
769
- ): Temporal.ZonedDateTime;
770
- toPlainYearMonth(): Temporal.PlainYearMonth;
771
- toPlainMonthDay(): Temporal.PlainMonthDay;
772
- toLocaleString(
773
- locales?: globalThis.Intl.LocalesArgument,
774
- options?: globalThis.Intl.DateTimeFormatOptions,
775
- ): string;
167
+ toPlainYearMonth(): PlainYearMonth;
168
+ toPlainMonthDay(): PlainMonthDay;
169
+ add(duration: DurationLike, options?: OverflowOptions): PlainDate;
170
+ subtract(duration: DurationLike, options?: OverflowOptions): PlainDate;
171
+ with(dateLike: PartialTemporalLike<DateLikeObject>, options?: OverflowOptions): PlainDate;
172
+ withCalendar(calendarLike: CalendarLike): PlainDate;
173
+ until(other: PlainDateLike, options?: RoundingOptionsWithLargestUnit<DateUnit>): Duration;
174
+ since(other: PlainDateLike, options?: RoundingOptionsWithLargestUnit<DateUnit>): Duration;
175
+ equals(other: PlainDateLike): boolean;
176
+ toPlainDateTime(time?: PlainTimeLike): PlainDateTime;
177
+ toZonedDateTime(timeZone: TimeZoneLike): ZonedDateTime;
178
+ toZonedDateTime(item: PlainDateToZonedDateTimeOptions): ZonedDateTime;
179
+ toString(options?: PlainDateToStringOptions): string;
180
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
776
181
  toJSON(): string;
777
- toString(options?: ShowCalendarOption): string;
778
182
  valueOf(): never;
779
183
  readonly [Symbol.toStringTag]: "Temporal.PlainDate";
780
184
  }
781
185
 
782
- export type PlainDateTimeLike = {
783
- era?: string | undefined;
784
- eraYear?: number | undefined;
785
- year?: number | undefined;
786
- month?: number | undefined;
787
- monthCode?: string | undefined;
788
- day?: number | undefined;
789
- hour?: number | undefined;
790
- minute?: number | undefined;
791
- second?: number | undefined;
792
- millisecond?: number | undefined;
793
- microsecond?: number | undefined;
794
- nanosecond?: number | undefined;
795
- calendar?: CalendarLike | undefined;
796
- };
186
+ interface PlainDateConstructor {
187
+ new (isoYear: number, isoMonth: number, isoDay: number, calendar?: string): PlainDate;
188
+ readonly prototype: PlainDate;
189
+ from(item: PlainDateLike, options?: OverflowOptions): PlainDate;
190
+ compare(one: PlainDateLike, two: PlainDateLike): number;
191
+ }
192
+ var PlainDate: PlainDateConstructor;
797
193
 
798
- /**
799
- * A `Temporal.PlainDateTime` represents a calendar date and wall-clock time, with
800
- * a precision in nanoseconds, and without any time zone. Of the Temporal
801
- * classes carrying human-readable time information, it is the most general
802
- * and complete one. `Temporal.PlainDate`, `Temporal.PlainTime`, `Temporal.PlainYearMonth`,
803
- * and `Temporal.PlainMonthDay` all carry less information and should be used when
804
- * complete information is not required.
805
- *
806
- * See https://tc39.es/proposal-temporal/docs/datetime.html for more details.
807
- */
808
- export class PlainDateTime {
809
- static from(
810
- item: Temporal.PlainDateTime | PlainDateTimeLike | string,
811
- options?: AssignmentOptions,
812
- ): Temporal.PlainDateTime;
813
- static compare(
814
- one: Temporal.PlainDateTime | PlainDateTimeLike | string,
815
- two: Temporal.PlainDateTime | PlainDateTimeLike | string,
816
- ): ComparisonResult;
817
- constructor(
818
- isoYear: number,
819
- isoMonth: number,
820
- isoDay: number,
194
+ interface PlainTimeToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<
195
+ Exclude<TimeUnit, "hour">
196
+ > {}
197
+
198
+ interface PlainTime {
199
+ readonly hour: number;
200
+ readonly minute: number;
201
+ readonly second: number;
202
+ readonly millisecond: number;
203
+ readonly microsecond: number;
204
+ readonly nanosecond: number;
205
+ add(duration: DurationLike): PlainTime;
206
+ subtract(duration: DurationLike): PlainTime;
207
+ with(timeLike: PartialTemporalLike<TimeLikeObject>, options?: OverflowOptions): PlainTime;
208
+ until(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
209
+ since(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
210
+ equals(other: PlainTimeLike): boolean;
211
+ round(roundTo: PluralizeUnit<TimeUnit>): PlainTime;
212
+ round(roundTo: RoundingOptions<TimeUnit>): PlainTime;
213
+ toString(options?: PlainTimeToStringOptions): string;
214
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
215
+ toJSON(): string;
216
+ valueOf(): never;
217
+ readonly [Symbol.toStringTag]: "Temporal.PlainTime";
218
+ }
219
+
220
+ interface PlainTimeConstructor {
221
+ new (
821
222
  hour?: number,
822
223
  minute?: number,
823
224
  second?: number,
824
225
  millisecond?: number,
825
226
  microsecond?: number,
826
227
  nanosecond?: number,
827
- calendar?: string,
828
- );
228
+ ): PlainTime;
229
+ readonly prototype: PlainTime;
230
+ from(item: PlainTimeLike, options?: OverflowOptions): PlainTime;
231
+ compare(one: PlainTimeLike, two: PlainTimeLike): number;
232
+ }
233
+ var PlainTime: PlainTimeConstructor;
234
+
235
+ interface PlainDateTimeToStringOptions
236
+ extends PlainDateToStringOptions, PlainTimeToStringOptions {}
237
+
238
+ interface PlainDateTime {
239
+ readonly calendarId: string;
829
240
  readonly era: string | undefined;
830
241
  readonly eraYear: number | undefined;
831
242
  readonly year: number;
@@ -838,298 +249,75 @@ export namespace Temporal {
838
249
  readonly millisecond: number;
839
250
  readonly microsecond: number;
840
251
  readonly nanosecond: number;
841
- readonly calendarId: string;
842
252
  readonly dayOfWeek: number;
843
253
  readonly dayOfYear: number;
844
254
  readonly weekOfYear: number | undefined;
845
255
  readonly yearOfWeek: number | undefined;
846
256
  readonly daysInWeek: number;
847
- readonly daysInYear: number;
848
257
  readonly daysInMonth: number;
258
+ readonly daysInYear: number;
849
259
  readonly monthsInYear: number;
850
260
  readonly inLeapYear: boolean;
851
- equals(other: Temporal.PlainDateTime | PlainDateTimeLike | string): boolean;
852
- with(dateTimeLike: PlainDateTimeLike, options?: AssignmentOptions): Temporal.PlainDateTime;
853
- withPlainTime(timeLike?: Temporal.PlainTime | PlainTimeLike | string): Temporal.PlainDateTime;
854
- withCalendar(calendar: CalendarLike): Temporal.PlainDateTime;
855
- add(
856
- durationLike: Temporal.Duration | DurationLike | string,
857
- options?: ArithmeticOptions,
858
- ): Temporal.PlainDateTime;
859
- subtract(
860
- durationLike: Temporal.Duration | DurationLike | string,
861
- options?: ArithmeticOptions,
862
- ): Temporal.PlainDateTime;
261
+ with(
262
+ dateTimeLike: PartialTemporalLike<DateTimeLikeObject>,
263
+ options?: OverflowOptions,
264
+ ): PlainDateTime;
265
+ withPlainTime(plainTime?: PlainTimeLike): PlainDateTime;
266
+ withCalendar(calendar: CalendarLike): PlainDateTime;
267
+ add(duration: DurationLike, options?: OverflowOptions): PlainDateTime;
268
+ subtract(duration: DurationLike, options?: OverflowOptions): PlainDateTime;
863
269
  until(
864
- other: Temporal.PlainDateTime | PlainDateTimeLike | string,
865
- options?: DifferenceOptions<
866
- | "year"
867
- | "month"
868
- | "week"
869
- | "day"
870
- | "hour"
871
- | "minute"
872
- | "second"
873
- | "millisecond"
874
- | "microsecond"
875
- | "nanosecond"
876
- >,
877
- ): Temporal.Duration;
270
+ other: PlainDateTimeLike,
271
+ options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>,
272
+ ): Duration;
878
273
  since(
879
- other: Temporal.PlainDateTime | PlainDateTimeLike | string,
880
- options?: DifferenceOptions<
881
- | "year"
882
- | "month"
883
- | "week"
884
- | "day"
885
- | "hour"
886
- | "minute"
887
- | "second"
888
- | "millisecond"
889
- | "microsecond"
890
- | "nanosecond"
891
- >,
892
- ): Temporal.Duration;
893
- round(
894
- roundTo: RoundTo<
895
- "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
896
- >,
897
- ): Temporal.PlainDateTime;
898
- toZonedDateTime(tzLike: TimeZoneLike, options?: ToInstantOptions): Temporal.ZonedDateTime;
899
- toPlainDate(): Temporal.PlainDate;
900
- toPlainTime(): Temporal.PlainTime;
901
- toLocaleString(
902
- locales?: globalThis.Intl.LocalesArgument,
903
- options?: globalThis.Intl.DateTimeFormatOptions,
904
- ): string;
274
+ other: PlainDateTimeLike,
275
+ options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>,
276
+ ): Duration;
277
+ round(roundTo: PluralizeUnit<"day" | TimeUnit>): PlainDateTime;
278
+ round(roundTo: RoundingOptions<"day" | TimeUnit>): PlainDateTime;
279
+ equals(other: PlainDateTimeLike): boolean;
280
+ toString(options?: PlainDateTimeToStringOptions): string;
281
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
905
282
  toJSON(): string;
906
- toString(options?: CalendarTypeToStringOptions): string;
907
283
  valueOf(): never;
284
+ toZonedDateTime(timeZone: TimeZoneLike, options?: DisambiguationOptions): ZonedDateTime;
285
+ toPlainDate(): PlainDate;
286
+ toPlainTime(): PlainTime;
908
287
  readonly [Symbol.toStringTag]: "Temporal.PlainDateTime";
909
288
  }
910
289
 
911
- export type PlainMonthDayLike = {
912
- era?: string | undefined;
913
- eraYear?: number | undefined;
914
- year?: number | undefined;
915
- month?: number | undefined;
916
- monthCode?: string | undefined;
917
- day?: number | undefined;
918
- calendar?: CalendarLike | undefined;
919
- };
920
-
921
- /**
922
- * A `Temporal.PlainMonthDay` represents a particular day on the calendar, but
923
- * without a year. For example, it could be used to represent a yearly
924
- * recurring event, like "Bastille Day is on the 14th of July."
925
- *
926
- * See https://tc39.es/proposal-temporal/docs/monthday.html for more details.
927
- */
928
- export class PlainMonthDay {
929
- static from(
930
- item: Temporal.PlainMonthDay | PlainMonthDayLike | string,
931
- options?: AssignmentOptions,
932
- ): Temporal.PlainMonthDay;
933
- constructor(isoMonth: number, isoDay: number, calendar?: string, referenceISOYear?: number);
934
- readonly monthCode: string;
935
- readonly day: number;
936
- readonly calendarId: string;
937
- equals(other: Temporal.PlainMonthDay | PlainMonthDayLike | string): boolean;
938
- with(monthDayLike: PlainMonthDayLike, options?: AssignmentOptions): Temporal.PlainMonthDay;
939
- toPlainDate(year: { year: number }): Temporal.PlainDate;
940
- toLocaleString(
941
- locales?: globalThis.Intl.LocalesArgument,
942
- options?: globalThis.Intl.DateTimeFormatOptions,
943
- ): string;
944
- toJSON(): string;
945
- toString(options?: ShowCalendarOption): string;
946
- valueOf(): never;
947
- readonly [Symbol.toStringTag]: "Temporal.PlainMonthDay";
948
- }
949
-
950
- export type PlainTimeLike = {
951
- hour?: number | undefined;
952
- minute?: number | undefined;
953
- second?: number | undefined;
954
- millisecond?: number | undefined;
955
- microsecond?: number | undefined;
956
- nanosecond?: number | undefined;
957
- };
958
-
959
- /**
960
- * A `Temporal.PlainTime` represents a wall-clock time, with a precision in
961
- * nanoseconds, and without any time zone. "Wall-clock time" refers to the
962
- * concept of a time as expressed in everyday usage — the time that you read
963
- * off the clock on the wall. For example, it could be used to represent an
964
- * event that happens daily at a certain time, no matter what time zone.
965
- *
966
- * `Temporal.PlainTime` refers to a time with no associated calendar date; if you
967
- * need to refer to a specific time on a specific day, use
968
- * `Temporal.PlainDateTime`. A `Temporal.PlainTime` can be converted into a
969
- * `Temporal.PlainDateTime` by combining it with a `Temporal.PlainDate` using the
970
- * `toPlainDateTime()` method.
971
- *
972
- * See https://tc39.es/proposal-temporal/docs/time.html for more details.
973
- */
974
- export class PlainTime {
975
- static from(
976
- item: Temporal.PlainTime | PlainTimeLike | string,
977
- options?: AssignmentOptions,
978
- ): Temporal.PlainTime;
979
- static compare(
980
- one: Temporal.PlainTime | PlainTimeLike | string,
981
- two: Temporal.PlainTime | PlainTimeLike | string,
982
- ): ComparisonResult;
983
- constructor(
290
+ interface PlainDateTimeConstructor {
291
+ new (
292
+ isoYear: number,
293
+ isoMonth: number,
294
+ isoDay: number,
984
295
  hour?: number,
985
296
  minute?: number,
986
297
  second?: number,
987
298
  millisecond?: number,
988
299
  microsecond?: number,
989
300
  nanosecond?: number,
990
- );
991
- readonly hour: number;
992
- readonly minute: number;
993
- readonly second: number;
994
- readonly millisecond: number;
995
- readonly microsecond: number;
996
- readonly nanosecond: number;
997
- equals(other: Temporal.PlainTime | PlainTimeLike | string): boolean;
998
- with(
999
- timeLike: Temporal.PlainTime | PlainTimeLike,
1000
- options?: AssignmentOptions,
1001
- ): Temporal.PlainTime;
1002
- add(
1003
- durationLike: Temporal.Duration | DurationLike | string,
1004
- options?: ArithmeticOptions,
1005
- ): Temporal.PlainTime;
1006
- subtract(
1007
- durationLike: Temporal.Duration | DurationLike | string,
1008
- options?: ArithmeticOptions,
1009
- ): Temporal.PlainTime;
1010
- until(
1011
- other: Temporal.PlainTime | PlainTimeLike | string,
1012
- options?: DifferenceOptions<
1013
- "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
1014
- >,
1015
- ): Temporal.Duration;
1016
- since(
1017
- other: Temporal.PlainTime | PlainTimeLike | string,
1018
- options?: DifferenceOptions<
1019
- "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
1020
- >,
1021
- ): Temporal.Duration;
1022
- round(
1023
- roundTo: RoundTo<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">,
1024
- ): Temporal.PlainTime;
1025
- toLocaleString(
1026
- locales?: globalThis.Intl.LocalesArgument,
1027
- options?: globalThis.Intl.DateTimeFormatOptions,
1028
- ): string;
1029
- toJSON(): string;
1030
- toString(options?: ToStringPrecisionOptions): string;
1031
- valueOf(): never;
1032
- readonly [Symbol.toStringTag]: "Temporal.PlainTime";
301
+ calendar?: string,
302
+ ): PlainDateTime;
303
+ readonly prototype: PlainDateTime;
304
+ from(item: PlainDateTimeLike, options?: OverflowOptions): PlainDateTime;
305
+ compare(one: PlainDateTimeLike, two: PlainDateTimeLike): number;
1033
306
  }
307
+ var PlainDateTime: PlainDateTimeConstructor;
1034
308
 
1035
- /**
1036
- * Any of these types can be passed to Temporal methods instead of a time zone ID.
1037
- * */
1038
- export type TimeZoneLike = string | ZonedDateTime;
1039
-
1040
- export type PlainYearMonthLike = {
1041
- era?: string | undefined;
1042
- eraYear?: number | undefined;
1043
- year?: number | undefined;
1044
- month?: number | undefined;
1045
- monthCode?: string | undefined;
1046
- calendar?: CalendarLike | undefined;
1047
- };
1048
-
1049
- /**
1050
- * A `Temporal.PlainYearMonth` represents a particular month on the calendar. For
1051
- * example, it could be used to represent a particular instance of a monthly
1052
- * recurring event, like "the June 2019 meeting".
1053
- *
1054
- * See https://tc39.es/proposal-temporal/docs/yearmonth.html for more details.
1055
- */
1056
- export class PlainYearMonth {
1057
- static from(
1058
- item: Temporal.PlainYearMonth | PlainYearMonthLike | string,
1059
- options?: AssignmentOptions,
1060
- ): Temporal.PlainYearMonth;
1061
- static compare(
1062
- one: Temporal.PlainYearMonth | PlainYearMonthLike | string,
1063
- two: Temporal.PlainYearMonth | PlainYearMonthLike | string,
1064
- ): ComparisonResult;
1065
- constructor(isoYear: number, isoMonth: number, calendar?: string, referenceISODay?: number);
1066
- readonly era: string | undefined;
1067
- readonly eraYear: number | undefined;
1068
- readonly year: number;
1069
- readonly month: number;
1070
- readonly monthCode: string;
1071
- readonly calendarId: string;
1072
- readonly daysInMonth: number;
1073
- readonly daysInYear: number;
1074
- readonly monthsInYear: number;
1075
- readonly inLeapYear: boolean;
1076
- equals(other: Temporal.PlainYearMonth | PlainYearMonthLike | string): boolean;
1077
- with(yearMonthLike: PlainYearMonthLike, options?: AssignmentOptions): Temporal.PlainYearMonth;
1078
- add(
1079
- durationLike: Temporal.Duration | DurationLike | string,
1080
- options?: ArithmeticOptions,
1081
- ): Temporal.PlainYearMonth;
1082
- subtract(
1083
- durationLike: Temporal.Duration | DurationLike | string,
1084
- options?: ArithmeticOptions,
1085
- ): Temporal.PlainYearMonth;
1086
- until(
1087
- other: Temporal.PlainYearMonth | PlainYearMonthLike | string,
1088
- options?: DifferenceOptions<"year" | "month">,
1089
- ): Temporal.Duration;
1090
- since(
1091
- other: Temporal.PlainYearMonth | PlainYearMonthLike | string,
1092
- options?: DifferenceOptions<"year" | "month">,
1093
- ): Temporal.Duration;
1094
- toPlainDate(day: { day: number }): Temporal.PlainDate;
1095
- toLocaleString(
1096
- locales?: globalThis.Intl.LocalesArgument,
1097
- options?: globalThis.Intl.DateTimeFormatOptions,
1098
- ): string;
1099
- toJSON(): string;
1100
- toString(options?: ShowCalendarOption): string;
1101
- valueOf(): never;
1102
- readonly [Symbol.toStringTag]: "Temporal.PlainYearMonth";
309
+ interface ZonedDateTimeToStringOptions extends PlainDateTimeToStringOptions {
310
+ offset?: "auto" | "never" | undefined;
311
+ timeZoneName?: "auto" | "never" | "critical" | undefined;
1103
312
  }
1104
313
 
1105
- export type ZonedDateTimeLike = {
1106
- era?: string | undefined;
1107
- eraYear?: number | undefined;
1108
- year?: number | undefined;
1109
- month?: number | undefined;
1110
- monthCode?: string | undefined;
1111
- day?: number | undefined;
1112
- hour?: number | undefined;
1113
- minute?: number | undefined;
1114
- second?: number | undefined;
1115
- millisecond?: number | undefined;
1116
- microsecond?: number | undefined;
1117
- nanosecond?: number | undefined;
1118
- offset?: string | undefined;
1119
- timeZone?: TimeZoneLike | undefined;
1120
- calendar?: CalendarLike | undefined;
1121
- };
314
+ interface ZonedDateTimeFromOptions extends OverflowOptions, DisambiguationOptions {
315
+ offset?: "use" | "ignore" | "prefer" | "reject" | undefined;
316
+ }
1122
317
 
1123
- export class ZonedDateTime {
1124
- static from(
1125
- item: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
1126
- options?: ZonedDateTimeAssignmentOptions,
1127
- ): ZonedDateTime;
1128
- static compare(
1129
- one: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
1130
- two: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
1131
- ): ComparisonResult;
1132
- constructor(epochNanoseconds: bigint, timeZone: string, calendar?: string);
318
+ interface ZonedDateTime {
319
+ readonly calendarId: string;
320
+ readonly timeZoneId: string;
1133
321
  readonly era: string | undefined;
1134
322
  readonly eraYear: number | undefined;
1135
323
  readonly year: number;
@@ -1142,8 +330,8 @@ export namespace Temporal {
1142
330
  readonly millisecond: number;
1143
331
  readonly microsecond: number;
1144
332
  readonly nanosecond: number;
1145
- readonly timeZoneId: string;
1146
- readonly calendarId: string;
333
+ readonly epochMilliseconds: number;
334
+ readonly epochNanoseconds: bigint;
1147
335
  readonly dayOfWeek: number;
1148
336
  readonly dayOfYear: number;
1149
337
  readonly weekOfYear: number | undefined;
@@ -1156,236 +344,269 @@ export namespace Temporal {
1156
344
  readonly inLeapYear: boolean;
1157
345
  readonly offsetNanoseconds: number;
1158
346
  readonly offset: string;
1159
- readonly epochMilliseconds: number;
1160
- readonly epochNanoseconds: bigint;
1161
- equals(other: Temporal.ZonedDateTime | ZonedDateTimeLike | string): boolean;
1162
347
  with(
1163
- zonedDateTimeLike: ZonedDateTimeLike,
1164
- options?: ZonedDateTimeAssignmentOptions,
1165
- ): Temporal.ZonedDateTime;
1166
- withPlainTime(timeLike?: Temporal.PlainTime | PlainTimeLike | string): Temporal.ZonedDateTime;
1167
- withCalendar(calendar: CalendarLike): Temporal.ZonedDateTime;
1168
- withTimeZone(timeZone: TimeZoneLike): Temporal.ZonedDateTime;
1169
- add(
1170
- durationLike: Temporal.Duration | DurationLike | string,
1171
- options?: ArithmeticOptions,
1172
- ): Temporal.ZonedDateTime;
1173
- subtract(
1174
- durationLike: Temporal.Duration | DurationLike | string,
1175
- options?: ArithmeticOptions,
1176
- ): Temporal.ZonedDateTime;
348
+ zonedDateTimeLike: PartialTemporalLike<ZonedDateTimeLikeObject>,
349
+ options?: ZonedDateTimeFromOptions,
350
+ ): ZonedDateTime;
351
+ withPlainTime(plainTime?: PlainTimeLike): ZonedDateTime;
352
+ withTimeZone(timeZone: TimeZoneLike): ZonedDateTime;
353
+ withCalendar(calendar: CalendarLike): ZonedDateTime;
354
+ add(duration: DurationLike, options?: OverflowOptions): ZonedDateTime;
355
+ subtract(duration: DurationLike, options?: OverflowOptions): ZonedDateTime;
1177
356
  until(
1178
- other: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
1179
- options?: Temporal.DifferenceOptions<
1180
- | "year"
1181
- | "month"
1182
- | "week"
1183
- | "day"
1184
- | "hour"
1185
- | "minute"
1186
- | "second"
1187
- | "millisecond"
1188
- | "microsecond"
1189
- | "nanosecond"
1190
- >,
1191
- ): Temporal.Duration;
357
+ other: ZonedDateTimeLike,
358
+ options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>,
359
+ ): Duration;
1192
360
  since(
1193
- other: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
1194
- options?: Temporal.DifferenceOptions<
1195
- | "year"
1196
- | "month"
1197
- | "week"
1198
- | "day"
1199
- | "hour"
1200
- | "minute"
1201
- | "second"
1202
- | "millisecond"
1203
- | "microsecond"
1204
- | "nanosecond"
1205
- >,
1206
- ): Temporal.Duration;
1207
- round(
1208
- roundTo: RoundTo<
1209
- "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
1210
- >,
1211
- ): Temporal.ZonedDateTime;
1212
- startOfDay(): Temporal.ZonedDateTime;
1213
- getTimeZoneTransition(direction: TransitionDirection): Temporal.ZonedDateTime | null;
1214
- toInstant(): Temporal.Instant;
1215
- toPlainDateTime(): Temporal.PlainDateTime;
1216
- toPlainDate(): Temporal.PlainDate;
1217
- toPlainTime(): Temporal.PlainTime;
1218
- toLocaleString(
1219
- locales?: globalThis.Intl.LocalesArgument,
1220
- options?: globalThis.Intl.DateTimeFormatOptions,
1221
- ): string;
1222
- toJSON(): string;
361
+ other: ZonedDateTimeLike,
362
+ options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>,
363
+ ): Duration;
364
+ round(roundTo: PluralizeUnit<"day" | TimeUnit>): ZonedDateTime;
365
+ round(roundTo: RoundingOptions<"day" | TimeUnit>): ZonedDateTime;
366
+ equals(other: ZonedDateTimeLike): boolean;
1223
367
  toString(options?: ZonedDateTimeToStringOptions): string;
368
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
369
+ toJSON(): string;
1224
370
  valueOf(): never;
371
+ startOfDay(): ZonedDateTime;
372
+ getTimeZoneTransition(direction: "next" | "previous"): ZonedDateTime | null;
373
+ getTimeZoneTransition(direction: TransitionOptions): ZonedDateTime | null;
374
+ toInstant(): Instant;
375
+ toPlainDate(): PlainDate;
376
+ toPlainTime(): PlainTime;
377
+ toPlainDateTime(): PlainDateTime;
1225
378
  readonly [Symbol.toStringTag]: "Temporal.ZonedDateTime";
1226
379
  }
1227
380
 
1228
- /**
1229
- * The `Temporal.Now` object has several methods which give information about
1230
- * the current date, time, and time zone.
1231
- *
1232
- * See https://tc39.es/proposal-temporal/docs/now.html for more details.
1233
- */
1234
- export const Now: {
1235
- /**
1236
- * Get the exact system date and time as a `Temporal.Instant`.
1237
- *
1238
- * This method gets the current exact system time, without regard to
1239
- * calendar or time zone. This is a good way to get a timestamp for an
1240
- * event, for example. It works like the old-style JavaScript `Date.now()`,
1241
- * but with nanosecond precision instead of milliseconds.
1242
- *
1243
- * Note that a `Temporal.Instant` doesn't know about time zones. For the
1244
- * exact time in a specific time zone, use `Temporal.Now.zonedDateTimeISO`
1245
- * or `Temporal.Now.zonedDateTime`.
1246
- * */
1247
- instant: () => Temporal.Instant;
381
+ interface ZonedDateTimeConstructor {
382
+ new (epochNanoseconds: bigint, timeZone: string, calendar?: string): ZonedDateTime;
383
+ readonly prototype: ZonedDateTime;
384
+ from(item: ZonedDateTimeLike, options?: ZonedDateTimeFromOptions): ZonedDateTime;
385
+ compare(one: ZonedDateTimeLike, two: ZonedDateTimeLike): number;
386
+ }
387
+ var ZonedDateTime: ZonedDateTimeConstructor;
1248
388
 
1249
- /**
1250
- * Get the current calendar date and clock time in a specific time zone,
1251
- * using the ISO 8601 calendar.
1252
- *
1253
- * @param {TimeZoneLike} [tzLike] -
1254
- * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier}
1255
- * string (e.g. `'Europe/London'`). If omitted, the environment's
1256
- * current time zone will be used.
1257
- */
1258
- zonedDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.ZonedDateTime;
389
+ interface DurationRelativeToOptions {
390
+ relativeTo?: ZonedDateTimeLike | PlainDateLike | undefined;
391
+ }
1259
392
 
1260
- /**
1261
- * Get the current date and clock time in a specific time zone, using the
1262
- * ISO 8601 calendar.
1263
- *
1264
- * Note that the `Temporal.PlainDateTime` type does not persist the time zone,
1265
- * but retaining the time zone is required for most time-zone-related use
1266
- * cases. Therefore, it's usually recommended to use
1267
- * `Temporal.Now.zonedDateTimeISO` instead of this function.
1268
- *
1269
- * @param {TimeZoneLike} [tzLike] -
1270
- * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier}
1271
- * string (e.g. `'Europe/London'`). If omitted, the environment's
1272
- * current time zone will be used.
1273
- */
1274
- plainDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainDateTime;
393
+ interface DurationRoundingOptions
394
+ extends DurationRelativeToOptions, RoundingOptionsWithLargestUnit<DateUnit | TimeUnit> {}
1275
395
 
1276
- /**
1277
- * Get the current date in a specific time zone, using the ISO 8601
1278
- * calendar.
1279
- *
1280
- * @param {TimeZoneLike} [tzLike] -
1281
- * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier}
1282
- * string (e.g. `'Europe/London'`). If omitted, the environment's
1283
- * current time zone will be used.
1284
- */
1285
- plainDateISO: (tzLike?: TimeZoneLike) => Temporal.PlainDate;
396
+ interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<
397
+ Exclude<TimeUnit, "hour" | "minute">
398
+ > {}
1286
399
 
1287
- /**
1288
- * Get the current clock time in a specific time zone, using the ISO 8601 calendar.
1289
- *
1290
- * @param {TimeZoneLike} [tzLike] -
1291
- * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone identifier}
1292
- * string (e.g. `'Europe/London'`). If omitted, the environment's
1293
- * current time zone will be used.
1294
- */
1295
- plainTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainTime;
400
+ interface DurationTotalOptions extends DurationRelativeToOptions {
401
+ unit: PluralizeUnit<DateUnit | TimeUnit>;
402
+ }
1296
403
 
1297
- /**
1298
- * Get the identifier of the environment's current time zone.
1299
- *
1300
- * This method gets the identifier of the current system time zone. This
1301
- * will usually be a named
1302
- * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones|IANA time zone}.
1303
- */
1304
- timeZoneId: () => string;
404
+ interface Duration {
405
+ readonly years: number;
406
+ readonly months: number;
407
+ readonly weeks: number;
408
+ readonly days: number;
409
+ readonly hours: number;
410
+ readonly minutes: number;
411
+ readonly seconds: number;
412
+ readonly milliseconds: number;
413
+ readonly microseconds: number;
414
+ readonly nanoseconds: number;
415
+ readonly sign: number;
416
+ readonly blank: boolean;
417
+ with(durationLike: PartialTemporalLike<DurationLikeObject>): Duration;
418
+ negated(): Duration;
419
+ abs(): Duration;
420
+ add(other: DurationLike): Duration;
421
+ subtract(other: DurationLike): Duration;
422
+ round(roundTo: PluralizeUnit<"day" | TimeUnit>): Duration;
423
+ round(roundTo: DurationRoundingOptions): Duration;
424
+ total(totalOf: PluralizeUnit<"day" | TimeUnit>): number;
425
+ total(totalOf: DurationTotalOptions): number;
426
+ toString(options?: DurationToStringOptions): string;
427
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions): string;
428
+ toJSON(): string;
429
+ valueOf(): never;
430
+ readonly [Symbol.toStringTag]: "Temporal.Duration";
431
+ }
1305
432
 
1306
- readonly [Symbol.toStringTag]: "Temporal.Now";
1307
- };
433
+ interface DurationConstructor {
434
+ new (
435
+ years?: number,
436
+ months?: number,
437
+ weeks?: number,
438
+ days?: number,
439
+ hours?: number,
440
+ minutes?: number,
441
+ seconds?: number,
442
+ milliseconds?: number,
443
+ microseconds?: number,
444
+ nanoseconds?: number,
445
+ ): Duration;
446
+ readonly prototype: Duration;
447
+ from(item: DurationLike): Duration;
448
+ compare(one: DurationLike, two: DurationLike, options?: DurationRelativeToOptions): number;
449
+ }
450
+ var Duration: DurationConstructor;
451
+
452
+ interface InstantToStringOptions extends PlainTimeToStringOptions {
453
+ timeZone?: TimeZoneLike | undefined;
454
+ }
455
+
456
+ interface Instant {
457
+ readonly epochMilliseconds: number;
458
+ readonly epochNanoseconds: bigint;
459
+ add(duration: DurationLike): Instant;
460
+ subtract(duration: DurationLike): Instant;
461
+ until(other: InstantLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
462
+ since(other: InstantLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
463
+ round(roundTo: PluralizeUnit<TimeUnit>): Instant;
464
+ round(roundTo: RoundingOptions<TimeUnit>): Instant;
465
+ equals(other: InstantLike): boolean;
466
+ toString(options?: InstantToStringOptions): string;
467
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
468
+ toJSON(): string;
469
+ valueOf(): never;
470
+ toZonedDateTimeISO(timeZone: TimeZoneLike): ZonedDateTime;
471
+ readonly [Symbol.toStringTag]: "Temporal.Instant";
472
+ }
473
+
474
+ interface InstantConstructor {
475
+ new (epochNanoseconds: bigint): Instant;
476
+ readonly prototype: Instant;
477
+ from(item: InstantLike): Instant;
478
+ fromEpochMilliseconds(epochMilliseconds: number): Instant;
479
+ fromEpochNanoseconds(epochNanoseconds: bigint): Instant;
480
+ compare(one: InstantLike, two: InstantLike): number;
481
+ }
482
+ var Instant: InstantConstructor;
483
+
484
+ interface PlainYearMonthToPlainDateOptions {
485
+ day: number;
486
+ }
487
+
488
+ interface PlainYearMonth {
489
+ readonly calendarId: string;
490
+ readonly era: string | undefined;
491
+ readonly eraYear: number | undefined;
492
+ readonly year: number;
493
+ readonly month: number;
494
+ readonly monthCode: string;
495
+ readonly daysInYear: number;
496
+ readonly daysInMonth: number;
497
+ readonly monthsInYear: number;
498
+ readonly inLeapYear: boolean;
499
+ with(
500
+ yearMonthLike: PartialTemporalLike<YearMonthLikeObject>,
501
+ options?: OverflowOptions,
502
+ ): PlainYearMonth;
503
+ add(duration: DurationLike, options?: OverflowOptions): PlainYearMonth;
504
+ subtract(duration: DurationLike, options?: OverflowOptions): PlainYearMonth;
505
+ until(
506
+ other: PlainYearMonthLike,
507
+ options?: RoundingOptionsWithLargestUnit<"year" | "month">,
508
+ ): Duration;
509
+ since(
510
+ other: PlainYearMonthLike,
511
+ options?: RoundingOptionsWithLargestUnit<"year" | "month">,
512
+ ): Duration;
513
+ equals(other: PlainYearMonthLike): boolean;
514
+ toString(options?: PlainDateToStringOptions): string;
515
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
516
+ toJSON(): string;
517
+ valueOf(): never;
518
+ toPlainDate(item: PlainYearMonthToPlainDateOptions): PlainDate;
519
+ readonly [Symbol.toStringTag]: "Temporal.PlainYearMonth";
520
+ }
521
+
522
+ interface PlainYearMonthConstructor {
523
+ new (
524
+ isoYear: number,
525
+ isoMonth: number,
526
+ calendar?: string,
527
+ referenceISODay?: number,
528
+ ): PlainYearMonth;
529
+ readonly prototype: PlainYearMonth;
530
+ from(item: PlainYearMonthLike, options?: OverflowOptions): PlainYearMonth;
531
+ compare(one: PlainYearMonthLike, two: PlainYearMonthLike): number;
532
+ }
533
+ var PlainYearMonth: PlainYearMonthConstructor;
534
+
535
+ interface PlainMonthDayToPlainDateOptions {
536
+ era?: string | undefined;
537
+ eraYear?: number | undefined;
538
+ year?: number | undefined;
539
+ }
540
+
541
+ interface PlainMonthDay {
542
+ readonly calendarId: string;
543
+ readonly monthCode: string;
544
+ readonly day: number;
545
+ with(
546
+ monthDayLike: PartialTemporalLike<DateLikeObject>,
547
+ options?: OverflowOptions,
548
+ ): PlainMonthDay;
549
+ equals(other: PlainMonthDayLike): boolean;
550
+ toString(options?: PlainDateToStringOptions): string;
551
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
552
+ toJSON(): string;
553
+ valueOf(): never;
554
+ toPlainDate(item: PlainMonthDayToPlainDateOptions): PlainDate;
555
+ readonly [Symbol.toStringTag]: "Temporal.PlainMonthDay";
556
+ }
557
+
558
+ interface PlainMonthDayConstructor {
559
+ new (
560
+ isoMonth: number,
561
+ isoDay: number,
562
+ calendar?: string,
563
+ referenceISOYear?: number,
564
+ ): PlainMonthDay;
565
+ readonly prototype: PlainMonthDay;
566
+ from(item: PlainMonthDayLike, options?: OverflowOptions): PlainMonthDay;
567
+ }
568
+ var PlainMonthDay: PlainMonthDayConstructor;
1308
569
  }
1309
570
 
1310
- declare namespace Intl {
1311
- type Formattable =
1312
- | Date
1313
- | Temporal.Instant
571
+ export namespace Intl {
572
+ type FormattableTemporalObject =
1314
573
  | Temporal.PlainDate
574
+ | Temporal.PlainYearMonth
575
+ | Temporal.PlainMonthDay
1315
576
  | Temporal.PlainTime
1316
577
  | Temporal.PlainDateTime
1317
- | Temporal.PlainYearMonth
1318
- | Temporal.PlainMonthDay;
578
+ | Temporal.Instant;
1319
579
 
1320
580
  export interface DateTimeFormat extends globalThis.Intl.DateTimeFormat {
1321
- /**
1322
- * Format a date into a string according to the locale and formatting
1323
- * options of this `Intl.DateTimeFormat` object.
1324
- *
1325
- * @param date The date to format.
1326
- */
1327
- format(date?: Formattable | number): string;
1328
-
1329
- /**
1330
- * Allow locale-aware formatting of strings produced by
1331
- * `Intl.DateTimeFormat` formatters.
1332
- *
1333
- * @param date The date to format.
1334
- */
1335
- formatToParts(date?: Formattable | number): globalThis.Intl.DateTimeFormatPart[];
1336
-
1337
- /**
1338
- * Format a date range in the most concise way based on the locale and
1339
- * options provided when instantiating this `Intl.DateTimeFormat` object.
1340
- *
1341
- * @param startDate The start date of the range to format.
1342
- * @param endDate The start date of the range to format. Must be the same
1343
- * type as `startRange`.
1344
- */
1345
- formatRange<T extends Formattable>(startDate: T, endDate: T): string;
1346
- formatRange(startDate: Date | number, endDate: Date | number): string;
1347
-
1348
- /**
1349
- * Allow locale-aware formatting of tokens representing each part of the
1350
- * formatted date range produced by `Intl.DateTimeFormat` formatters.
1351
- *
1352
- * @param startDate The start date of the range to format.
1353
- * @param endDate The start date of the range to format. Must be the same
1354
- * type as `startRange`.
1355
- */
1356
- formatRangeToParts<T extends Formattable>(
1357
- startDate: T,
1358
- endDate: T,
1359
- ): globalThis.Intl.DateTimeRangeFormatPart[];
581
+ format(date?: FormattableTemporalObject | Date | number): string;
582
+ formatToParts(date?: FormattableTemporalObject | Date | number): DateTimeFormatPart[];
583
+ formatRange(
584
+ startDate: FormattableTemporalObject | Date | number,
585
+ endDate: FormattableTemporalObject | Date | number,
586
+ ): string;
1360
587
  formatRangeToParts(
1361
- startDate: Date | number,
1362
- endDate: Date | number,
1363
- ): globalThis.Intl.DateTimeRangeFormatPart[];
588
+ startDate: FormattableTemporalObject | Date | number,
589
+ endDate: FormattableTemporalObject | Date | number,
590
+ ): DateTimeRangeFormatPart[];
1364
591
  }
592
+ }
1365
593
 
1366
- export const DateTimeFormat: {
1367
- /**
1368
- * Creates `Intl.DateTimeFormat` objects that enable language-sensitive
1369
- * date and time formatting.
1370
- */
594
+ export const Intl: {
595
+ DateTimeFormat: {
1371
596
  new (
1372
597
  locales?: string | string[],
1373
598
  options?: globalThis.Intl.DateTimeFormatOptions,
1374
- ): DateTimeFormat;
1375
- (locales?: string | string[], options?: globalThis.Intl.DateTimeFormatOptions): DateTimeFormat;
599
+ ): Intl.DateTimeFormat;
600
+ (
601
+ locales?: string | string[],
602
+ options?: globalThis.Intl.DateTimeFormatOptions,
603
+ ): Intl.DateTimeFormat;
1376
604
 
1377
- /**
1378
- * Get an array containing those of the provided locales that are supported
1379
- * in date and time formatting without having to fall back to the runtime's
1380
- * default locale.
1381
- */
1382
605
  supportedLocalesOf(
1383
606
  locales: string | string[],
1384
607
  options?: globalThis.Intl.DateTimeFormatOptions,
1385
608
  ): string[];
1386
609
  };
1387
- }
1388
-
1389
- export { Intl as Intl };
610
+ };
1390
611
 
1391
612
  export function toTemporalInstant(this: Date): Temporal.Instant;