forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesnext.temporal.d.ts
More file actions
469 lines (423 loc) · 21.2 KB
/
esnext.temporal.d.ts
File metadata and controls
469 lines (423 loc) · 21.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
/// <reference lib="es2015.symbol.wellknown" />
/// <reference lib="es2020.intl" />
/// <reference lib="es2025.intl" />
declare namespace Temporal {
type CalendarLike = PlainDate | PlainDateTime | PlainMonthDay | PlainYearMonth | ZonedDateTime | string;
type DurationLike = Duration | DurationLikeObject | string;
type InstantLike = Instant | ZonedDateTime | string;
type PlainDateLike = PlainDate | ZonedDateTime | PlainDateTime | DateLikeObject | string;
type PlainDateTimeLike = PlainDateTime | ZonedDateTime | PlainDate | DateTimeLikeObject | string;
type PlainMonthDayLike = PlainMonthDay | DateLikeObject | string;
type PlainTimeLike = PlainTime | PlainDateTime | ZonedDateTime | TimeLikeObject | string;
type PlainYearMonthLike = PlainYearMonth | YearMonthLikeObject | string;
type TimeZoneLike = ZonedDateTime | string;
type ZonedDateTimeLike = ZonedDateTime | ZonedDateTimeLikeObject | string;
type PartialTemporalLike<T extends object> = {
[P in Exclude<keyof T, "calendar" | "timeZone">]?: T[P] | undefined;
};
interface DateLikeObject {
year?: number | undefined;
era?: string | undefined;
eraYear?: number | undefined;
month?: number | undefined;
monthCode?: string | undefined;
day: number;
calendar?: string | undefined;
}
interface DateTimeLikeObject extends DateLikeObject, TimeLikeObject {}
interface DurationLikeObject {
years?: number | undefined;
months?: number | undefined;
weeks?: number | undefined;
days?: number | undefined;
hours?: number | undefined;
minutes?: number | undefined;
seconds?: number | undefined;
milliseconds?: number | undefined;
microseconds?: number | undefined;
nanoseconds?: number | undefined;
}
interface TimeLikeObject {
hour?: number | undefined;
minute?: number | undefined;
second?: number | undefined;
millisecond?: number | undefined;
microsecond?: number | undefined;
nanosecond?: number | undefined;
}
interface YearMonthLikeObject extends Omit<DateLikeObject, "day"> {}
interface ZonedDateTimeLikeObject extends DateTimeLikeObject {
timeZone: TimeZoneLike;
offset?: string | undefined;
}
type DateUnit = "year" | "month" | "week" | "day";
type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond";
type PluralizeUnit<T extends DateUnit | TimeUnit> =
| T
| {
year: "years";
month: "months";
week: "weeks";
day: "days";
hour: "hours";
minute: "minutes";
second: "seconds";
millisecond: "milliseconds";
microsecond: "microseconds";
nanosecond: "nanoseconds";
}[T];
interface DisambiguationOptions {
disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined;
}
interface OverflowOptions {
overflow?: "constrain" | "reject" | undefined;
}
interface TransitionOptions {
direction: "next" | "previous";
}
interface RoundingOptions<Units extends DateUnit | TimeUnit> {
smallestUnit?: PluralizeUnit<Units> | undefined;
roundingIncrement?: number | undefined;
roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined;
}
interface RoundingOptionsWithLargestUnit<Units extends DateUnit | TimeUnit> extends RoundingOptions<Units> {
largestUnit?: "auto" | PluralizeUnit<Units> | undefined;
}
interface ToStringRoundingOptions<Units extends DateUnit | TimeUnit> extends Pick<RoundingOptions<Units>, "smallestUnit" | "roundingMode"> {}
interface ToStringRoundingOptionsWithFractionalSeconds<Units extends DateUnit | TimeUnit> extends ToStringRoundingOptions<Units> {
fractionalSecondDigits?: "auto" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
}
namespace Now {
function timeZoneId(): string;
function instant(): Instant;
function plainDateTimeISO(timeZone?: TimeZoneLike): PlainDateTime;
function zonedDateTimeISO(timeZone?: TimeZoneLike): ZonedDateTime;
function plainDateISO(timeZone?: TimeZoneLike): PlainDate;
function plainTimeISO(timeZone?: TimeZoneLike): PlainTime;
}
interface PlainDateToStringOptions {
calendarName?: "auto" | "always" | "never" | "critical" | undefined;
}
interface PlainDateToZonedDateTimeOptions {
plainTime?: PlainTimeLike | undefined;
timeZone: TimeZoneLike;
}
interface PlainDate {
readonly calendarId: string;
readonly era: string | undefined;
readonly eraYear: number | undefined;
readonly year: number;
readonly month: number;
readonly monthCode: string;
readonly day: number;
readonly dayOfWeek: number;
readonly dayOfYear: number;
readonly weekOfYear: number | undefined;
readonly yearOfWeek: number | undefined;
readonly daysInWeek: number;
readonly daysInMonth: number;
readonly daysInYear: number;
readonly monthsInYear: number;
readonly inLeapYear: boolean;
toPlainYearMonth(): PlainYearMonth;
toPlainMonthDay(): PlainMonthDay;
add(duration: DurationLike, options?: OverflowOptions): PlainDate;
subtract(duration: DurationLike, options?: OverflowOptions): PlainDate;
with(dateLike: PartialTemporalLike<DateLikeObject>, options?: OverflowOptions): PlainDate;
withCalendar(calendarLike: CalendarLike): PlainDate;
until(other: PlainDateLike, options?: RoundingOptionsWithLargestUnit<DateUnit>): Duration;
since(other: PlainDateLike, options?: RoundingOptionsWithLargestUnit<DateUnit>): Duration;
equals(other: PlainDateLike): boolean;
toPlainDateTime(time?: PlainTimeLike): PlainDateTime;
toZonedDateTime(timeZone: TimeZoneLike): ZonedDateTime;
toZonedDateTime(item: PlainDateToZonedDateTimeOptions): ZonedDateTime;
toString(options?: PlainDateToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
readonly [Symbol.toStringTag]: "Temporal.PlainDate";
}
interface PlainDateConstructor {
new (isoYear: number, isoMonth: number, isoDay: number, calendar?: string): PlainDate;
readonly prototype: PlainDate;
from(item: PlainDateLike, options?: OverflowOptions): PlainDate;
compare(one: PlainDateLike, two: PlainDateLike): number;
}
var PlainDate: PlainDateConstructor;
interface PlainTimeToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<Exclude<TimeUnit, "hour">> {}
interface PlainTime {
readonly hour: number;
readonly minute: number;
readonly second: number;
readonly millisecond: number;
readonly microsecond: number;
readonly nanosecond: number;
add(duration: DurationLike): PlainTime;
subtract(duration: DurationLike): PlainTime;
with(timeLike: PartialTemporalLike<TimeLikeObject>, options?: OverflowOptions): PlainTime;
until(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
since(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
equals(other: PlainTimeLike): boolean;
round(roundTo: PluralizeUnit<TimeUnit>): PlainTime;
round(roundTo: RoundingOptions<TimeUnit>): PlainTime;
toString(options?: PlainTimeToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
readonly [Symbol.toStringTag]: "Temporal.PlainTime";
}
interface PlainTimeConstructor {
new (hour?: number, minute?: number, second?: number, millisecond?: number, microsecond?: number, nanosecond?: number): PlainTime;
readonly prototype: PlainTime;
from(item: PlainTimeLike, options?: OverflowOptions): PlainTime;
compare(one: PlainTimeLike, two: PlainTimeLike): number;
}
var PlainTime: PlainTimeConstructor;
interface PlainDateTimeToStringOptions extends PlainDateToStringOptions, PlainTimeToStringOptions {}
interface PlainDateTime {
readonly calendarId: string;
readonly era: string | undefined;
readonly eraYear: number | undefined;
readonly year: number;
readonly month: number;
readonly monthCode: string;
readonly day: number;
readonly hour: number;
readonly minute: number;
readonly second: number;
readonly millisecond: number;
readonly microsecond: number;
readonly nanosecond: number;
readonly dayOfWeek: number;
readonly dayOfYear: number;
readonly weekOfYear: number | undefined;
readonly yearOfWeek: number | undefined;
readonly daysInWeek: number;
readonly daysInMonth: number;
readonly daysInYear: number;
readonly monthsInYear: number;
readonly inLeapYear: boolean;
with(dateTimeLike: PartialTemporalLike<DateTimeLikeObject>, options?: OverflowOptions): PlainDateTime;
withPlainTime(plainTime?: PlainTimeLike): PlainDateTime;
withCalendar(calendar: CalendarLike): PlainDateTime;
add(duration: DurationLike, options?: OverflowOptions): PlainDateTime;
subtract(duration: DurationLike, options?: OverflowOptions): PlainDateTime;
until(other: PlainDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
since(other: PlainDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
round(roundTo: PluralizeUnit<"day" | TimeUnit>): PlainDateTime;
round(roundTo: RoundingOptions<"day" | TimeUnit>): PlainDateTime;
equals(other: PlainDateTimeLike): boolean;
toString(options?: PlainDateTimeToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
toZonedDateTime(timeZone: TimeZoneLike, options?: DisambiguationOptions): ZonedDateTime;
toPlainDate(): PlainDate;
toPlainTime(): PlainTime;
readonly [Symbol.toStringTag]: "Temporal.PlainDateTime";
}
interface PlainDateTimeConstructor {
new (isoYear: number, isoMonth: number, isoDay: number, hour?: number, minute?: number, second?: number, millisecond?: number, microsecond?: number, nanosecond?: number, calendar?: string): PlainDateTime;
readonly prototype: PlainDateTime;
from(item: PlainDateTimeLike, options?: OverflowOptions): PlainDateTime;
compare(one: PlainDateTimeLike, two: PlainDateTimeLike): number;
}
var PlainDateTime: PlainDateTimeConstructor;
interface ZonedDateTimeToStringOptions extends PlainDateTimeToStringOptions {
offset?: "auto" | "never" | undefined;
timeZoneName?: "auto" | "never" | "critical" | undefined;
}
interface ZonedDateTimeFromOptions extends OverflowOptions, DisambiguationOptions {
offset?: "use" | "ignore" | "prefer" | "reject" | undefined;
}
interface ZonedDateTime {
readonly calendarId: string;
readonly timeZoneId: string;
readonly era: string | undefined;
readonly eraYear: number | undefined;
readonly year: number;
readonly month: number;
readonly monthCode: string;
readonly day: number;
readonly hour: number;
readonly minute: number;
readonly second: number;
readonly millisecond: number;
readonly microsecond: number;
readonly nanosecond: number;
readonly epochMilliseconds: number;
readonly epochNanoseconds: bigint;
readonly dayOfWeek: number;
readonly dayOfYear: number;
readonly weekOfYear: number | undefined;
readonly yearOfWeek: number | undefined;
readonly hoursInDay: number;
readonly daysInWeek: number;
readonly daysInMonth: number;
readonly daysInYear: number;
readonly monthsInYear: number;
readonly inLeapYear: boolean;
readonly offsetNanoseconds: number;
readonly offset: string;
with(zonedDateTimeLike: PartialTemporalLike<ZonedDateTimeLikeObject>, options?: ZonedDateTimeFromOptions): ZonedDateTime;
withPlainTime(plainTime?: PlainTimeLike): ZonedDateTime;
withTimeZone(timeZone: TimeZoneLike): ZonedDateTime;
withCalendar(calendar: CalendarLike): ZonedDateTime;
add(duration: DurationLike, options?: OverflowOptions): ZonedDateTime;
subtract(duration: DurationLike, options?: OverflowOptions): ZonedDateTime;
until(other: ZonedDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
since(other: ZonedDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
round(roundTo: PluralizeUnit<"day" | TimeUnit>): ZonedDateTime;
round(roundTo: RoundingOptions<"day" | TimeUnit>): ZonedDateTime;
equals(other: ZonedDateTimeLike): boolean;
toString(options?: ZonedDateTimeToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
startOfDay(): ZonedDateTime;
getTimeZoneTransition(direction: "next" | "previous"): ZonedDateTime | null;
getTimeZoneTransition(direction: TransitionOptions): ZonedDateTime | null;
toInstant(): Instant;
toPlainDate(): PlainDate;
toPlainTime(): PlainTime;
toPlainDateTime(): PlainDateTime;
readonly [Symbol.toStringTag]: "Temporal.ZonedDateTime";
}
interface ZonedDateTimeConstructor {
new (epochNanoseconds: bigint, timeZone: string, calendar?: string): ZonedDateTime;
readonly prototype: ZonedDateTime;
from(item: ZonedDateTimeLike, options?: ZonedDateTimeFromOptions): ZonedDateTime;
compare(one: ZonedDateTimeLike, two: ZonedDateTimeLike): number;
}
var ZonedDateTime: ZonedDateTimeConstructor;
interface DurationRelativeToOptions {
relativeTo?: ZonedDateTimeLike | PlainDateLike | undefined;
}
interface DurationRoundingOptions extends DurationRelativeToOptions, RoundingOptionsWithLargestUnit<DateUnit | TimeUnit> {}
interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<Exclude<TimeUnit, "hour" | "minute">> {}
interface DurationTotalOptions extends DurationRelativeToOptions {
unit: PluralizeUnit<DateUnit | TimeUnit>;
}
interface Duration {
readonly years: number;
readonly months: number;
readonly weeks: number;
readonly days: number;
readonly hours: number;
readonly minutes: number;
readonly seconds: number;
readonly milliseconds: number;
readonly microseconds: number;
readonly nanoseconds: number;
readonly sign: number;
readonly blank: boolean;
with(durationLike: PartialTemporalLike<DurationLikeObject>): Duration;
negated(): Duration;
abs(): Duration;
add(other: DurationLike): Duration;
subtract(other: DurationLike): Duration;
round(roundTo: PluralizeUnit<"day" | TimeUnit>): Duration;
round(roundTo: DurationRoundingOptions): Duration;
total(totalOf: PluralizeUnit<"day" | TimeUnit>): number;
total(totalOf: DurationTotalOptions): number;
toString(options?: DurationToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions): string;
toJSON(): string;
valueOf(): never;
readonly [Symbol.toStringTag]: "Temporal.Duration";
}
interface DurationConstructor {
new (years?: number, months?: number, weeks?: number, days?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number, microseconds?: number, nanoseconds?: number): Duration;
readonly prototype: Duration;
from(item: DurationLike): Duration;
compare(one: DurationLike, two: DurationLike, options?: DurationRelativeToOptions): number;
}
var Duration: DurationConstructor;
interface InstantToStringOptions extends PlainTimeToStringOptions {
timeZone?: TimeZoneLike | undefined;
}
interface Instant {
readonly epochMilliseconds: number;
readonly epochNanoseconds: bigint;
add(duration: DurationLike): Instant;
subtract(duration: DurationLike): Instant;
until(other: InstantLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
since(other: InstantLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
round(roundTo: PluralizeUnit<TimeUnit>): Instant;
round(roundTo: RoundingOptions<TimeUnit>): Instant;
equals(other: InstantLike): boolean;
toString(options?: InstantToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
toZonedDateTimeISO(timeZone: TimeZoneLike): ZonedDateTime;
readonly [Symbol.toStringTag]: "Temporal.Instant";
}
interface InstantConstructor {
new (epochNanoseconds: bigint): Instant;
readonly prototype: Instant;
from(item: InstantLike): Instant;
fromEpochMilliseconds(epochMilliseconds: number): Instant;
fromEpochNanoseconds(epochNanoseconds: bigint): Instant;
compare(one: InstantLike, two: InstantLike): number;
}
var Instant: InstantConstructor;
interface PlainYearMonthToPlainDateOptions {
day: number;
}
interface PlainYearMonth {
readonly calendarId: string;
readonly era: string | undefined;
readonly eraYear: number | undefined;
readonly year: number;
readonly month: number;
readonly monthCode: string;
readonly daysInYear: number;
readonly daysInMonth: number;
readonly monthsInYear: number;
readonly inLeapYear: boolean;
with(yearMonthLike: PartialTemporalLike<YearMonthLikeObject>, options?: OverflowOptions): PlainYearMonth;
add(duration: DurationLike, options?: OverflowOptions): PlainYearMonth;
subtract(duration: DurationLike, options?: OverflowOptions): PlainYearMonth;
until(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month">): Duration;
since(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month">): Duration;
equals(other: PlainYearMonthLike): boolean;
toString(options?: PlainDateToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
toPlainDate(item: PlainYearMonthToPlainDateOptions): PlainDate;
readonly [Symbol.toStringTag]: "Temporal.PlainYearMonth";
}
interface PlainYearMonthConstructor {
new (isoYear: number, isoMonth: number, calendar?: string, referenceISODay?: number): PlainYearMonth;
readonly prototype: PlainYearMonth;
from(item: PlainYearMonthLike, options?: OverflowOptions): PlainYearMonth;
compare(one: PlainYearMonthLike, two: PlainYearMonthLike): number;
}
var PlainYearMonth: PlainYearMonthConstructor;
interface PlainMonthDayToPlainDateOptions {
era?: string | undefined;
eraYear?: number | undefined;
year?: number | undefined;
}
interface PlainMonthDay {
readonly calendarId: string;
readonly monthCode: string;
readonly day: number;
with(monthDayLike: PartialTemporalLike<DateLikeObject>, options?: OverflowOptions): PlainMonthDay;
equals(other: PlainMonthDayLike): boolean;
toString(options?: PlainDateToStringOptions): string;
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
valueOf(): never;
toPlainDate(item: PlainMonthDayToPlainDateOptions): PlainDate;
readonly [Symbol.toStringTag]: "Temporal.PlainMonthDay";
}
interface PlainMonthDayConstructor {
new (isoMonth: number, isoDay: number, calendar?: string, referenceISOYear?: number): PlainMonthDay;
readonly prototype: PlainMonthDay;
from(item: PlainMonthDayLike, options?: OverflowOptions): PlainMonthDay;
}
var PlainMonthDay: PlainMonthDayConstructor;
}