diff options
Diffstat (limited to 'src/temporal-ambient.d.ts')
| -rw-r--r-- | src/temporal-ambient.d.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/temporal-ambient.d.ts b/src/temporal-ambient.d.ts new file mode 100644 index 0000000..f6080b0 --- /dev/null +++ b/src/temporal-ambient.d.ts @@ -0,0 +1,54 @@ +// Minimal ambient Temporal declarations (native runtime, no polyfill). +// Covers only what this app uses; extend as needed. If a future TS lib +// ships Temporal types, these merge with them. + +declare global { + namespace Temporal { + type TimeZoneId = string; + type DurationLike = { + days?: number; + hours?: number; + milliseconds?: number; + }; + + interface Duration { + total(options: { unit: 'millisecond' | 'day' }): number; + } + namespace Duration { + function from(durationLike: DurationLike): Duration; + } + + interface Instant { + readonly epochMilliseconds: number; + add(durationLike: { hours?: number; milliseconds?: number }): Instant; + toString(options?: { smallestUnit?: 'millisecond' }): string; + toZonedDateTimeISO(timeZone: TimeZoneId): ZonedDateTime; + toLocaleString( + locales?: string | string[], + options?: Intl.DateTimeFormatOptions, + ): string; + } + namespace Instant { + function compare(a: string | Instant, b: string | Instant): number; + function from(iso: string): Instant; + function fromEpochMilliseconds(ms: number): Instant; + } + + interface ZonedDateTime { + add(durationLike: DurationLike): ZonedDateTime; + startOfDay(): ZonedDateTime; + toInstant(): Instant; + toLocaleString( + locales?: string | string[], + options?: Intl.DateTimeFormatOptions, + ): string; + } + + namespace Now { + function instant(): Instant; + function timeZoneId(): TimeZoneId; + } + } +} + +export {}; |
