diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 03e9febadb306..c17cc4ef9ca01 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -251,11 +251,13 @@ const libEntries: [string, string][] = [ // ESNext By-feature options ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.collection", "lib.esnext.collection.d.ts"], + ["esnext.date", "lib.esnext.date.d.ts"], ["esnext.decorators", "lib.esnext.decorators.d.ts"], ["esnext.disposable", "lib.esnext.disposable.d.ts"], ["esnext.error", "lib.esnext.error.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.sharedmemory", "lib.esnext.sharedmemory.d.ts"], + ["esnext.temporal", "lib.esnext.temporal.d.ts"], ["esnext.typedarrays", "lib.esnext.typedarrays.d.ts"], // Decorators ["decorators", "lib.decorators.d.ts"], diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 73ef240f16ade..38425f9ab052e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1953,6 +1953,11 @@ export const getScriptTargetFeatures: () => ScriptTargetFeatures = /* @__PURE__ "fromHex", ], })), + Date: new Map(Object.entries({ + esnext: [ + "toTemporalInstant", + ], + })), DisposableStack: new Map(Object.entries({ esnext: emptyArray, })), diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index f25c6cbad53bd..10d459816a349 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -7,3 +7,5 @@ /// /// /// +/// +/// diff --git a/src/lib/esnext.date.d.ts b/src/lib/esnext.date.d.ts new file mode 100644 index 0000000000000..1e5e90421c5a0 --- /dev/null +++ b/src/lib/esnext.date.d.ts @@ -0,0 +1,5 @@ +/// + +interface Date { + toTemporalInstant(): Temporal.Instant; +} diff --git a/src/lib/esnext.intl.d.ts b/src/lib/esnext.intl.d.ts index 238148375f3b4..bca52717b8fec 100644 --- a/src/lib/esnext.intl.d.ts +++ b/src/lib/esnext.intl.d.ts @@ -1,4 +1,15 @@ +/// + declare namespace Intl { + type FormattableTemporalObject = Temporal.PlainDate | Temporal.PlainYearMonth | Temporal.PlainMonthDay | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.Instant; + + interface DateTimeFormat { + format(date?: FormattableTemporalObject | Date | number): string; + formatToParts(date?: FormattableTemporalObject | Date | number): DateTimeFormatPart[]; + formatRange(startDate: FormattableTemporalObject | Date | number, endDate: FormattableTemporalObject | Date | number): string; + formatRangeToParts(startDate: FormattableTemporalObject | Date | number, endDate: FormattableTemporalObject | Date | number): DateTimeRangeFormatPart[]; + } + interface Locale { /** * Returns a list of one or more unique calendar identifiers for this locale. diff --git a/src/lib/esnext.temporal.d.ts b/src/lib/esnext.temporal.d.ts new file mode 100644 index 0000000000000..6bbfa071a7dfe --- /dev/null +++ b/src/lib/esnext.temporal.d.ts @@ -0,0 +1,457 @@ +/// +/// +/// + +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 | MonthDayLikeObject | string; + type PlainTimeLike = PlainTime | PlainDateTime | ZonedDateTime | TimeLikeObject | string; + type PlainYearMonthLike = PlainYearMonth | YearMonthLikeObject | string; + type TimeZoneLike = ZonedDateTime | string; + type ZonedDateTimeLike = ZonedDateTime | ZonedDateTimeLikeObject | string; + + type PartialTemporalLike = { + [P in Exclude]?: 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 MonthDayLikeObject extends Omit {} + + interface TimeLikeObject { + hour?: number | undefined; + minute?: number | undefined; + second?: number | undefined; + millisecond?: number | undefined; + microsecond?: number | undefined; + nanosecond?: number | undefined; + } + + interface YearMonthLikeObject extends Omit {} + + interface ZonedDateTimeLikeObject extends DateTimeLikeObject { + timeZone: TimeZoneLike; + offset?: string | undefined; + } + + type DateUnit = "year" | "month" | "week" | "day" | "years" | "months" | "weeks" | "days"; + type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds"; + + interface DisambiguationOptions { + disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined; + } + + interface OverflowOptions { + overflow?: "constrain" | "reject" | undefined; + } + + interface TransitionOptions { + direction: "next" | "previous"; + } + + interface RoundingOptions { + smallestUnit?: Units | undefined; + roundingIncrement?: number | undefined; + roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined; + } + + interface RoundingOptionsWithLargestUnit extends RoundingOptions { + largestUnit?: "auto" | Units | undefined; + } + + interface ToStringRoundingOptions extends Pick, "smallestUnit" | "roundingMode"> {} + + interface ToStringRoundingOptionsWithFractionalSeconds extends ToStringRoundingOptions { + 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, options?: OverflowOptions): PlainDate; + withCalendar(calendarLike: CalendarLike): PlainDate; + until(other: PlainDateLike, options?: RoundingOptionsWithLargestUnit): Duration; + since(other: PlainDateLike, options?: RoundingOptionsWithLargestUnit): 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> {} + + 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, options?: OverflowOptions): PlainTime; + until(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit): Duration; + since(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit): Duration; + equals(other: PlainTimeLike): boolean; + round(roundTo: TimeUnit): PlainTime; + round(roundTo: RoundingOptions): 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, 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): Duration; + since(other: PlainDateTimeLike, options?: RoundingOptionsWithLargestUnit): Duration; + round(roundTo: "day" | "days" | TimeUnit): PlainDateTime; + round(roundTo: RoundingOptions<"day" | "days" | 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, 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): Duration; + since(other: ZonedDateTimeLike, options?: RoundingOptionsWithLargestUnit): Duration; + round(roundTo: "day" | "days" | TimeUnit): ZonedDateTime; + round(roundTo: RoundingOptions<"day" | "days" | 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 {} + + interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds> {} + + interface DurationTotalOptions extends DurationRelativeToOptions { + unit: 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): Duration; + negated(): Duration; + abs(): Duration; + add(other: DurationLike): Duration; + subtract(other: DurationLike): Duration; + round(roundTo: "day" | "days" | TimeUnit): Duration; + round(roundTo: DurationRoundingOptions): Duration; + total(totalOf: "day" | "days" | 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): Duration; + since(other: InstantLike, options?: RoundingOptionsWithLargestUnit): Duration; + round(roundTo: TimeUnit): Instant; + round(roundTo: RoundingOptions): 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, options?: OverflowOptions): PlainYearMonth; + add(duration: DurationLike, options?: OverflowOptions): PlainYearMonth; + subtract(duration: DurationLike, options?: OverflowOptions): PlainYearMonth; + until(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">): Duration; + since(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">): 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, 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; +} diff --git a/src/lib/libs.json b/src/lib/libs.json index c7b0c29ac6f84..5bc6a8b57a2c1 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -88,11 +88,13 @@ "es2025.regexp", "esnext.array", "esnext.collection", + "esnext.date", "esnext.decorators", "esnext.disposable", "esnext.error", "esnext.intl", "esnext.sharedmemory", + "esnext.temporal", "esnext.typedarrays", "decorators", "decorators.legacy", diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js index 68e88242ebc4a..b87a17312cbff 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: es7,0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js index 50c59c841ca8d..598824639e89a 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: es7,0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js index 15bbe4083991a..451a40f1e6d70 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: 0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js index 8651034f8145b..736451ea62470 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js @@ -30,5 +30,5 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js index a26993ede82a3..efdc3e007901e 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js @@ -30,7 +30,7 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. 8 ""    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js index 2fcf5a63abc08..e3a3ec4e0a604 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js @@ -33,5 +33,5 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js index 98ec91f34eed6..c527cd039f5cb 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js @@ -33,7 +33,7 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -tsconfig.json:9:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +tsconfig.json:9:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. 9 ""    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js index 090d4f0127deb..984e934a5391f 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js @@ -35,5 +35,5 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js index f0c0d9ddff3b9..a71071fc8db67 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js @@ -35,7 +35,7 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -tsconfig.json:10:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +tsconfig.json:10:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. 10 "incorrectLib"    ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js index fdbd4c1c4f16b..18f74ba74d1b0 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js @@ -30,5 +30,5 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js index e694c27fb17c7..2eb47cabb2582 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js @@ -30,7 +30,7 @@ CompilerOptions:: "configFilePath": "/apath/tsconfig.json" } Errors:: -tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. +tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'. 8 " "    ~~~~~ diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt index 0bc0cc1bc35d3..15df2d938b1bc 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt @@ -37,9 +37,10 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(39,47): error TS2550: Property ' doYouNeedToChangeYourTargetLibraryES2016Plus.ts(40,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(43,32): error TS2550: Property 'any' does not exist on type 'PromiseConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(47,46): error TS2550: Property 'toTemporalInstant' does not exist on type 'Date'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later. -==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (39 errors) ==== +==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (40 errors) ==== // es2016 const testIncludes = ["hello"].includes("world"); ~~~~~~~~ @@ -164,4 +165,7 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): error TS2550: Property ' !!! error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. // esnext + const testDateToTemporalInstant = new Date().toTemporalInstant(); + ~~~~~~~~~~~~~~~~~ +!!! error TS2550: Property 'toTemporalInstant' does not exist on type 'Date'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later. \ No newline at end of file diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js index cf4c6cddd8698..f4dfd3fa637da 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.js @@ -47,6 +47,7 @@ const testPromiseAny = Promise.any([]); const testStringReplaceAll = "".replaceAll(); // esnext +const testDateToTemporalInstant = new Date().toTemporalInstant(); //// [doYouNeedToChangeYourTargetLibraryES2016Plus.js] @@ -91,3 +92,4 @@ const testBigInt = BigInt(123); const testPromiseAny = Promise.any([]); const testStringReplaceAll = "".replaceAll(); // esnext +const testDateToTemporalInstant = new Date().toTemporalInstant(); diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols index 562c539287906..373692987b76c 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.symbols @@ -132,4 +132,7 @@ const testStringReplaceAll = "".replaceAll(); >testStringReplaceAll : Symbol(testStringReplaceAll, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 43, 5)) // esnext +const testDateToTemporalInstant = new Date().toTemporalInstant(); +>testDateToTemporalInstant : Symbol(testDateToTemporalInstant, Decl(doYouNeedToChangeYourTargetLibraryES2016Plus.ts, 46, 5)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types index ff708c5879b54..c568b6bdcf57f 100644 --- a/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types +++ b/tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2016Plus.types @@ -454,4 +454,17 @@ const testStringReplaceAll = "".replaceAll(); > : ^^^ // esnext +const testDateToTemporalInstant = new Date().toTemporalInstant(); +>testDateToTemporalInstant : any +> : ^^^ +>new Date().toTemporalInstant() : any +> : ^^^ +>new Date().toTemporalInstant : any +> : ^^^ +>new Date() : Date +> : ^^^^ +>Date : DateConstructor +> : ^^^^^^^^^^^^^^^ +>toTemporalInstant : any +> : ^^^ diff --git a/tests/baselines/reference/formatToPartsFractionalSecond.symbols b/tests/baselines/reference/formatToPartsFractionalSecond.symbols index d3b69b2692cf9..ec278826a5987 100644 --- a/tests/baselines/reference/formatToPartsFractionalSecond.symbols +++ b/tests/baselines/reference/formatToPartsFractionalSecond.symbols @@ -3,11 +3,11 @@ === formatToPartsFractionalSecond.ts === new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractionalSecond') >new Intl.DateTimeFormat().formatToParts().find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->new Intl.DateTimeFormat().formatToParts : Symbol(Intl.DateTimeFormat.formatToParts, Decl(lib.es2017.intl.d.ts, --, --)) ->Intl.DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>new Intl.DateTimeFormat().formatToParts : Symbol(Intl.DateTimeFormat.formatToParts, Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) +>Intl.DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) >Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2016.intl.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --) ... and 7 more) ->DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) ->formatToParts : Symbol(Intl.DateTimeFormat.formatToParts, Decl(lib.es2017.intl.d.ts, --, --)) +>DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) +>formatToParts : Symbol(Intl.DateTimeFormat.formatToParts, Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) >find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >val : Symbol(val, Decl(formatToPartsFractionalSecond.ts, 0, 48)) >val.type : Symbol(Intl.DateTimeFormatPart.type, Decl(lib.es2017.intl.d.ts, --, --)) diff --git a/tests/baselines/reference/formatToPartsFractionalSecond.types b/tests/baselines/reference/formatToPartsFractionalSecond.types index 6a32ce572f5c8..e975a8ef11a1b 100644 --- a/tests/baselines/reference/formatToPartsFractionalSecond.types +++ b/tests/baselines/reference/formatToPartsFractionalSecond.types @@ -8,8 +8,8 @@ new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractional > : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >new Intl.DateTimeFormat().formatToParts() : Intl.DateTimeFormatPart[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^ ->new Intl.DateTimeFormat().formatToParts : (date?: Date | number) => Intl.DateTimeFormatPart[] -> : ^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>new Intl.DateTimeFormat().formatToParts : { (date?: Date | number): Intl.DateTimeFormatPart[]; (date?: Intl.FormattableTemporalObject | Date | number): Intl.DateTimeFormatPart[]; } +> : ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ >new Intl.DateTimeFormat() : Intl.DateTimeFormat > : ^^^^^^^^^^^^^^^^^^^ >Intl.DateTimeFormat : Intl.DateTimeFormatConstructor @@ -18,8 +18,8 @@ new Intl.DateTimeFormat().formatToParts().find((val) => val.type === 'fractional > : ^^^^^^^^^^^ >DateTimeFormat : Intl.DateTimeFormatConstructor > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->formatToParts : (date?: Date | number) => Intl.DateTimeFormatPart[] -> : ^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>formatToParts : { (date?: Date | number): Intl.DateTimeFormatPart[]; (date?: Intl.FormattableTemporalObject | Date | number): Intl.DateTimeFormatPart[]; } +> : ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ >find : { (predicate: (value: Intl.DateTimeFormatPart, index: number, obj: Intl.DateTimeFormatPart[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: Intl.DateTimeFormatPart, index: number, obj: Intl.DateTimeFormatPart[]) => unknown, thisArg?: any): Intl.DateTimeFormatPart | undefined; } > : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >(val) => val.type === 'fractionalSecond' : (val: Intl.DateTimeFormatPart) => boolean diff --git a/tests/baselines/reference/libReplacement(libreplacement=true).trace.json b/tests/baselines/reference/libReplacement(libreplacement=true).trace.json index 48193d8a42c7d..0931f0cce71f9 100644 --- a/tests/baselines/reference/libReplacement(libreplacement=true).trace.json +++ b/tests/baselines/reference/libReplacement(libreplacement=true).trace.json @@ -1013,6 +1013,19 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/temporal' from '/.src/__lib_node_modules_lookup_lib.esnext.temporal.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/temporal' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/temporal'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/temporal'", + "Loading module '@typescript/lib-esnext/temporal' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/temporal' was not resolved. ========", "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", @@ -1103,5 +1116,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-esnext/typedarrays' was not resolved. ========" + "======== Module name '@typescript/lib-esnext/typedarrays' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/date' from '/.src/__lib_node_modules_lookup_lib.esnext.date.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/date' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/date'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/date'", + "Loading module '@typescript/lib-esnext/date' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/date' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/temporal.errors.txt b/tests/baselines/reference/temporal.errors.txt new file mode 100644 index 0000000000000..5ab55589f8214 --- /dev/null +++ b/tests/baselines/reference/temporal.errors.txt @@ -0,0 +1,1834 @@ +temporal.ts(25,13): error TS2339: Property 'year' does not exist on type 'Instant'. +temporal.ts(1502,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'. +temporal.ts(1512,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'. +temporal.ts(1518,8): error TS2339: Property 'month' does not exist on type 'PlainMonthDay'. + + +==== temporal.ts (4 errors) ==== + /** + * Test cases derived from documentation at tc39/proposal-temporal, + * under the following license: + * + * Copyright 2017, 2018, 2019, 2020 ECMA International + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + { + const instant = Temporal.Instant.from("2020-01-01T00:00+05:30"); // => 2019-12-31T18:30:00Z + instant.epochNanoseconds; // => 1577817000000000000n + + // `Temporal.Instant` lacks properties that depend on time zone or calendar + instant.year; // => undefined + ~~~~ +!!! error TS2339: Property 'year' does not exist on type 'Instant'. + + const zdtTokyo = instant.toZonedDateTimeISO("Asia/Tokyo"); // => 2020-01-01T03:30:00+09:00[Asia/Tokyo] + zdtTokyo.year; // => 2020 + zdtTokyo.toPlainDate(); // => 2020-01-01 + } + + { + // Convert from `Temporal.Instant` to `Date` (which uses millisecond precision) + const instant = Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30"); + // => 2019-12-31T18:30:00.123456789Z + const date = new Date(instant.epochMilliseconds); + date.toISOString(); // => 2019-12-31T18:30:00.123Z + + // Convert from `Date` to `Temporal.Instant` + const sameInstant = date.toTemporalInstant(); // => 2019-12-31T18:30:00.123Z + } + + { + const date = new Date(2019, 11, 31, 18, 30); // => Tue Dec 31 2019 18:30:00 GMT-0800 (Pacific Standard Time) + const instant = date.toTemporalInstant(); // => 2020-01-01T02:30:00Z + const zonedDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()); + // => 2019-12-31T18:30:00-08:00[America/Los_Angeles] + zonedDateTime.day; // => 31 + const dateOnly = zonedDateTime.toPlainDate(); // => 2019-12-31 + } + + { + const instant = new Temporal.Instant(1553906700000000000n); + // When was the Unix epoch? + const epoch = new Temporal.Instant(0n); // => 1970-01-01T00:00:00Z + // Dates before the Unix epoch are negative + const turnOfTheCentury = new Temporal.Instant(-2208988800000000000n); // => 1900-01-01T00:00:00Z + } + + { + let instant: Temporal.Instant; + instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]"); + instant = Temporal.Instant.from("2019-03-30T01:45+01:00"); + instant = Temporal.Instant.from("2019-03-30T00:45Z"); + instant === Temporal.Instant.from(instant); // => false + } + + { + const legacyDate = new Date("1995-12-17T03:24Z"); + let instant: Temporal.Instant; + instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()); // => 1995-12-17T03:24:00Z + instant = legacyDate.toTemporalInstant(); // recommended + } + + { + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + const three = Temporal.Instant.fromEpochMilliseconds(1.2e12); + const sorted = [three, one, two].sort(Temporal.Instant.compare); + sorted.join(" "); + // => '2001-09-09T01:46:40Z 2004-11-09T11:33:20Z 2008-01-10T21:20:00Z' + } + + { + const instant = Temporal.Instant.from("2019-03-30T00:45Z"); + new Date(instant.epochMilliseconds); // => 2019-03-30T00:45:00.000Z + + // If you need epoch seconds data: + const epochSecs = Math.floor(instant.epochMilliseconds / 1000); // => 1553906700 + + const ns = instant.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); + } + + { + // Converting a specific exact time to a calendar date / wall-clock time + let timestamp: Temporal.Instant; + timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100_000); + timestamp.toZonedDateTimeISO("Europe/Berlin"); // => 2019-03-31T01:45:00+01:00[Europe/Berlin] + timestamp.toZonedDateTimeISO("UTC"); // => 2019-03-31T00:45:00+00:00[UTC] + timestamp.toZonedDateTimeISO("-08:00"); // => 2019-03-30T16:45:00-08:00[-08:00] + + // What time was the Unix epoch (timestamp 0) in Bell Labs (Murray Hill, New Jersey, USA) in the Gregorian calendar? + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory"); + // => 1969-12-31T19:00:00-05:00[America/New_York][u-ca=gregory] + + // What time was the Unix epoch in Tokyo in the Japanese calendar? + const zdt = epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese"); + // => 1970-01-01T09:00:00+09:00[Asia/Tokyo][u-ca=japanese] + console.log(zdt.eraYear, zdt.era); + // => '45 showa' + } + + { + // Temporal.Instant representing five hours from now + Temporal.Now.instant().add({ hours: 5 }); + const fiveHours = Temporal.Duration.from({ hours: 5 }); + Temporal.Now.instant().add(fiveHours); + } + + { + // Temporal.Instant representing this time an hour ago + Temporal.Now.instant().subtract({ hours: 1 }); + const oneHour = Temporal.Duration.from({ hours: 1 }); + Temporal.Now.instant().subtract(oneHour); + } + + { + const startOfMoonMission = Temporal.Instant.from("1969-07-16T13:32:00Z"); + const endOfMoonMission = Temporal.Instant.from("1969-07-24T16:50:35Z"); + const missionLength = startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }); + // => PT195H18M35S + missionLength.toLocaleString(); + // example output: '195 hours 18 minutes 35 seconds' + + // Rounding, for example if you don't care about the minutes and seconds + const approxMissionLength = startOfMoonMission.until(endOfMoonMission, { + largestUnit: "hour", + smallestUnit: "hour", + }); + // => PT195H + + // A billion (10^9) seconds since the epoch in different units + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + const billion = Temporal.Instant.fromEpochMilliseconds(1e9); + epoch.until(billion); + // => PT1000000000S + epoch.until(billion, { largestUnit: "hour" }); + // => PT277777H46M40S + const ns = epoch.until(billion, { largestUnit: "nanosecond" }); + // => PT1000000000S + ns.add({ nanoseconds: 1 }); + // => PT1000000000S + // (lost precision) + + // Calculate the difference in years, eliminating the ambiguity by + // explicitly using the corresponding calendar date in UTC: + epoch.toZonedDateTimeISO("UTC").until( + billion.toZonedDateTimeISO("UTC"), + { largestUnit: "year" }, + ); + // => P31Y8M8DT1H46M40S + } + + { + const instant = Temporal.Instant.from("2019-03-30T02:45:59.999999999Z"); + + // Round to a particular unit + instant.round({ smallestUnit: "second" }); // => 2019-03-30T02:46:00Z + // Round to an increment of a unit, e.g. an hour: + instant.round({ roundingIncrement: 60, smallestUnit: "minute" }); + // => 2019-03-30T03:00:00Z + // Round to the same increment but round down instead: + instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }); + // => 2019-03-30T02:00:00Z + } + + { + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + one.equals(two); // => false + one.equals(one); // => true + } + + { + const instant = Temporal.Instant.fromEpochMilliseconds(1574074321816); + instant.toString(); // => '2019-11-18T10:52:01.816Z' + instant.toString({ timeZone: "UTC" }); + // => '2019-11-18T10:52:01.816+00:00' + instant.toString({ timeZone: "Asia/Seoul" }); + // => '2019-11-18T19:52:01.816+09:00' + + instant.toString({ smallestUnit: "minute" }); + // => '2019-11-18T10:52Z' + instant.toString({ fractionalSecondDigits: 0 }); + // => '2019-11-18T10:52:01Z' + instant.toString({ fractionalSecondDigits: 4 }); + // => '2019-11-18T10:52:01.8160Z' + instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }); + // => '2019-11-18T10:52:02Z' + } + + { + const instant = Temporal.Instant.from("2019-11-18T11:00:00.000Z"); + instant.toLocaleString(); // example output: '2019-11-18, 3:00:00 a.m.' + instant.toLocaleString("de-DE"); // example output: '18.11.2019, 03:00:00' + instant.toLocaleString("de-DE", { + timeZone: "Europe/Berlin", + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + timeZoneName: "long", + }); // => '18.11.2019, 12:00 Mitteleuropäische Normalzeit' + instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { + timeZone: "Asia/Kolkata", + }); // => '11/18/2019, 4:30:00 PM' + } + + { + // UNIX epoch in California + new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + // same, but shorter + } + + { + let zdt: Temporal.ZonedDateTime; + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); + zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); + + zdt = Temporal.ZonedDateTime.from({ + timeZone: "America/Los_Angeles", + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] + + // Different overflow modes + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00+01:00[Europe/Paris] + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws RangeError + } + + { + const arr = [ + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), + ]; + const sorted = arr.sort(Temporal.ZonedDateTime.compare); + JSON.stringify(sorted, undefined, 2); + // => + // '[ + // "2020-02-01T12:30+01:00[Europe/Brussels]", + // "2020-02-01T12:30+00:00[Europe/London]", + // "2020-02-01T12:30-05:00[America/Toronto]", + // "2020-02-01T12:30-05:00[America/New_York]" + // ]' + } + + { + const dt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 + } + + { + const zdt = Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]"); + const epochMs = zdt.epochMilliseconds; + // => 1580527800000 + zdt.toInstant().epochMilliseconds; + // => 1580527800000 + const legacyDate = new Date(epochMs); + // => 2020-02-01T03:30:00.000Z + // (if the system time zone is America/Los_Angeles) + const epochNanos = zdt.epochNanoseconds; + // => 1580527800000000000n + + // If you need epoch seconds data: + const epochSecs = Math.floor(zdt.epochMilliseconds / 1000); // => 1553906700 + // => 1580527800 + + // If you need epoch microseconds data: + // (Note the extra check for correct floor rounding with bigints) + const ns = zdt.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); + // => 1580527800000000n + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + `Time zone is: ${zdt.timeZoneId}`; + // => 'Time zone is: America/Los_Angeles' + zdt.withTimeZone("Asia/Kolkata").timeZoneId; + // => Asia/Kolkata + zdt.withTimeZone("Asia/Calcutta").timeZoneId; + // => Asia/Calcutta (does not follow links in the IANA Time Zone Database) + + zdt.withTimeZone("europe/paris").timeZoneId; + // => Europe/Paris (normalized to match IANA Time Zone Database capitalization) + + zdt.withTimeZone("+05:00").timeZoneId; + // => +05:00 + zdt.withTimeZone("+05").timeZoneId; + // => +05:00 (normalized to ±HH:MM) + zdt.withTimeZone("+0500").timeZoneId; + // => +05:00 (normalized to ±HH:MM) + } + + { + const date = Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1]; // => 'THU' + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + // ISO ordinal date + console.log(zdt.year, zdt.dayOfYear); // => '1995 341' + } + + { + const zdt = Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]"); + // ISO week date + console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek); // => '2021 52 6' + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + zdt.daysInWeek; // => 7 + } + + { + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const zdt = Temporal.Now.zonedDateTimeISO().with({ month }); + monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt); + } + + const strings = monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); + } + + { + const zdt = Temporal.Now.zonedDateTimeISO(); + const percent = zdt.dayOfYear / zdt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" + } + + { + const zdt = Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]"); + zdt.monthsInYear; // => 12 + } + + { + // Is this year a leap year? + const zdt = Temporal.Now.zonedDateTimeISO(); + zdt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + zdt.with({ year: 2100 }).inLeapYear; // => false + } + + { + const zdt = Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]"); + zdt.hoursInDay; // 25 + } + + { + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offsetNanoseconds; + // => -25200000000000 + // (-7 * 3600 * 1e9) + } + + { + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offset; + // => '-07:00' + zdt.withTimeZone("Asia/Kolkata").offset; + // => '+05:30' + + const minus8Hours = "-08:00"; + const daylightTime0130 = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + // => 2020-11-01T01:30:00-07:00[America/Los_Angeles] + // This is Pacific Daylight Time 1:30AM + const repeated0130 = daylightTime0130.with({ offset: minus8Hours }); + // => 2020-11-01T01:30:00-08:00[America/Los_Angeles] + // This is Pacific Standard Time 1:30AM + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]"); + zdt.with({ year: 2015, minute: 31 }); // => 2015-12-07T03:31:00-06:00[America/Chicago] + } + + { + const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + zdt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00-08:00[America/Los_Angeles] + const time = Temporal.PlainTime.from("11:22"); + zdt.withPlainTime(time); // => 2015-12-07T11:22:00-08:00[America/Los_Angeles] + zdt.withPlainTime("12:34"); // => 2015-12-07T12:34:00-08:00[America/Los_Angeles] + + // easier for chaining + zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00-08:00[America/Los_Angeles] + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]"); + zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]' + zdt.withTimeZone("Africa/Accra").toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]' + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]"); + `${zdt.era} ${zdt.eraYear}`; // => 'heisei 7' + zdt.withCalendar("gregory").eraYear; // => 1995 + } + + { + const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const laterDay = zdt.add({ days: 1 }); + // => 2020-03-09T00:00:00-07:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + laterDay.since(zdt, { largestUnit: "hour" }).hours; + // => 23 + // because one clock hour lost to DST + + const laterHours = zdt.add({ hours: 24 }); + // => 2020-03-09T01:00:00-07:00[America/Los_Angeles] + // Adding time units doesn't adjust for DST. Result is 1:00AM: 24 real-world + // hours later because a clock hour was skipped by DST. + laterHours.since(zdt, { largestUnit: "hour" }).hours; // => 24 + } + + { + const zdt = Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const earlierDay = zdt.subtract({ days: 1 }); + // => 2020-03-08T00:00:00-08:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + earlierDay.since(zdt, { largestUnit: "hour" }).hours; + // => -23 + // because one clock hour lost to DST + + const earlierHours = zdt.subtract({ hours: 24 }); + // => 2020-03-07T23:00:00-08:00[America/Los_Angeles] + // Subtracting time units doesn't adjust for DST. Result is 11:00PM: 24 real-world + // hours earlier because a clock hour was skipped by DST. + earlierHours.since(zdt, { largestUnit: "hour" }).hours; // => -24 + } + + { + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt1.until(zdt2); + // => PT202956H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + zdt2.until(zdt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + zdt1.until(zdt2, { smallestUnit: "second" }); + // => PT202956H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })); + jan1.until(feb1, { largestUnit: "day" }); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1, { largestUnit: "day" }); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1, { largestUnit: "day" }); // => P60D + } + + { + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt2.since(zdt1); // => PT202956H5M29.9999965S + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + + // Round to a particular unit + zdt.round({ smallestUnit: "hour" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + // Round to an increment of a unit, e.g. half an hour: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00-08:00[America/Los_Angeles] + // Round to the same increment but round down instead: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + } + + { + const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); + zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] + } + + { + let duration: Temporal.Duration; + // How long until the next offset change from now, in the current location? + const tz = Temporal.Now.timeZoneId(); + const now = Temporal.Now.zonedDateTimeISO(tz); + const nextTransition = now.getTimeZoneTransition("next"); + duration = nextTransition!.since(now); + duration.toLocaleString(); // output will vary + + // How long until the previous offset change from now, in the current location? + const previousTransition = now.getTimeZoneTransition("previous"); + duration = now.since(previousTransition!); + duration.toLocaleString(); // output will vary + } + + { + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]"); + const zdt2 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]"); + zdt1.equals(zdt2); // => false (same offset but different time zones) + zdt1.equals(zdt1); // => true + + // To compare time zone IDs, use withTimeZone() with each ID on the same + // ZonedDateTime instance, and use equals() to compare + const kolkata = zdt1.withTimeZone("Asia/Kolkata"); + kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")); // => true + + // Offset time zones are never equivalent to named time zones + kolkata.equals(zdt1.withTimeZone("+05:30")); // => false + const zeroOffset = zdt1.withTimeZone("+00:00"); + zeroOffset.equals(zdt1.withTimeZone("UTC")); // => false + + // For offset time zones, any valid format is accepted + zeroOffset.equals(zdt1.withTimeZone("+00:00")); // => true + zeroOffset.equals(zdt1.withTimeZone("+0000")); // => true + zeroOffset.equals(zdt1.withTimeZone("+00")); // => true + } + + { + let zdt: Temporal.ZonedDateTime; + zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos]' + zdt = zdt.withCalendar("japanese"); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos][u-ca=japanese]' + } + + { + const zdt = Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]"); + zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM + zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' + const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; + zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' + /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); + // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin + zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' + zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' + } + + { + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]"); + zdt.toInstant(); // => 1995-12-07T01:24:30Z + zdt.toPlainDateTime(); // => 1995-12-07T03:24:30 + zdt.toPlainDate(); // => 1995-12-07 + zdt.toPlainTime(); // => 03:24:30 + zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 + zdt.toPlainDate().toPlainMonthDay(); // => 12-07 + } + + { + // Pi day in 2020 + const date = new Temporal.PlainDate(2020, 3, 14); // => 2020-03-14 + } + + { + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); // => 2006-08-24 + date = Temporal.PlainDate.from("20060824"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 2006-08-24 + date === Temporal.PlainDate.from(date); // => false + + date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24 + date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")); + // => 2006-08-24 + // same as above; Temporal.PlainDateTime has year, month, and day properties + + date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }); + // => 2006-08-24[u-ca=islamic] + + // Different overflow modes + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01 + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31 + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws + } + + { + const one = Temporal.PlainDate.from("2006-08-24"); + const two = Temporal.PlainDate.from("2015-07-14"); + const three = Temporal.PlainDate.from("1930-02-18"); + const sorted = [one, two, three].sort(Temporal.PlainDate.compare); + sorted.join(" "); // => '1930-02-18 2006-08-24 2015-07-14' + } + + { + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.year; // => 2006 + date.month; // => 8 + date.monthCode; // => 'M08' + date.day; // => 24 + + date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]"); + date.year; // => 5779 + date.month; // => 6 + date.monthCode; // => 'M05L' + date.day; // => 18 + } + + { + const date = Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1]; // => 'THU' + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + // ISO ordinal date + console.log(date.year, date.dayOfYear); // => '2006 236' + } + + { + const date = Temporal.PlainDate.from("2022-01-01"); + // ISO week date + console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek); // => '2021 52 6' + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + date.daysInWeek; // => 7 + } + + { + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const date = Temporal.Now.plainDateISO().with({ month }); + monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date); + } + + const strings = monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); + } + + { + const date = Temporal.Now.plainDateISO(); + const percent = date.dayOfYear / date.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" + } + + { + const date = Temporal.PlainDate.from("1900-01-01"); + date.monthsInYear; // => 12 + } + + { + // Is this year a leap year? + const date = Temporal.Now.plainDateISO(); + date.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + date.with({ year: 2100 }).inLeapYear; // => false + } + + { + const date = Temporal.PlainDate.from("2006-01-24"); + // What's the first day of this month? + date.with({ day: 1 }); // => 2006-01-01 + // What's the last day of the next month? + const nextMonthDate = date.add({ months: 1 }); + nextMonthDate.with({ day: nextMonthDate.daysInMonth }); // => 2006-02-28 + } + + { + const date = Temporal.PlainDate.from("2006-08-24[u-ca=japanese]"); + date.withCalendar("iso8601"); // => 2006-08-24 + } + + { + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.add({ years: 20, months: 4 }); // => 2026-12-24 + + date = Temporal.PlainDate.from("2019-01-31"); + date.add({ months: 1 }); // => 2019-02-28 + date.add({ months: 1 }, { overflow: "reject" }); // => throws + } + + { + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.subtract({ years: 20, months: 4 }); // => 1986-04-24 + + date = Temporal.PlainDate.from("2019-03-31"); + date.subtract({ months: 1 }); // => 2019-02-28 + date.subtract({ months: 1 }, { overflow: "reject" }); // => throws + } + + { + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + earlier.until(later); // => P4543D + earlier.until(later, { largestUnit: "year" }); // => P12Y5M7D + later.until(earlier, { largestUnit: "year" }); // => -P12Y5M7D + + // If you really need to calculate the difference between two Dates in + // hours, you can eliminate the ambiguity by explicitly choosing the + // point in time from which you want to reckon the difference. For + // example, using noon: + const noon = Temporal.PlainTime.from("12:00"); + earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }); + // => PT109032H + + const newyear = Temporal.PlainDate.from("2020-01-01"); + newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S + newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S (mid-month dates rounded down to match `Temporal.PlainDateTime` behavior) + newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT1M + } + + { + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + later.since(earlier); // => P4543D + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + const other = Temporal.PlainDate.from("2019-01-31"); + date.equals(other); // => false + date.equals(date); // => true + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + date.toString(); // => '2006-08-24' + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + date.toLocaleString(); // example output: 8/24/2006 + date.toLocaleString("de-DE"); // example output: '24.8.2006' + date.toLocaleString("de-DE", { weekday: "long" }); // => 'Donnerstag' + date.toLocaleString("en-US-u-nu-fullwide"); // => '8/24/2006' + } + + { + const plainDate = Temporal.PlainDate.from("2006-08-24"); + const plainTime = Temporal.PlainTime.from("15:23:30.003"); + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }); + // => 2006-08-24T15:23:30.003-07:00[America/Los_Angeles] + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }); + // => 2006-08-24T00:00:00-07:00[America/Los_Angeles] + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + const time = Temporal.PlainTime.from("15:23:30.003"); + date.toPlainDateTime(time); // => 2006-08-24T15:23:30.003 + date.toPlainDateTime(); // => 2006-08-24T00:00:00 + } + + { + const date = Temporal.PlainDate.from("2006-08-24"); + date.toPlainYearMonth(); // => 2006-08 + date.toPlainMonthDay(); // => 08-24 + } + + { + // Leet hour + const time = new Temporal.PlainTime(13, 37); // => 13:37:00 + } + + { + let time: Temporal.PlainTime; + + time = Temporal.PlainTime.from("03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("032430"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 03:24:30 + // (same as above; time zone is ignored) + time === Temporal.PlainTime.from(time); // => false + + time = Temporal.PlainTime.from({ + hour: 19, + minute: 39, + second: 9, + millisecond: 68, + microsecond: 346, + nanosecond: 205, + }); // => 19:39:09.068346205 + time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }); // => 19:39:09 + time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")); + // => 19:39:09 + // (same as above; Temporal.PlainDateTime has hour, minute, etc. properties) + + // Different overflow modes + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }); + // => 15:59:00 + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }); + // => 15:00:00 + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }); + // => throws + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }); + // => throws + } + + { + const one = Temporal.PlainTime.from("03:24"); + const two = Temporal.PlainTime.from("01:24"); + const three = Temporal.PlainTime.from("01:24:05"); + const sorted = [one, two, three].sort(Temporal.PlainTime.compare); + sorted.join(" "); // => '01:24:00 01:24:05 03:24:00' + } + + { + // Backward transitions will repeat clock times + const zdtDst = Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]"); + const zdtStandard = Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]"); + // The "first" 1:45 (in Daylight Time) is earlier than the "second" 1:30 (in Standard Time) + Temporal.ZonedDateTime.compare(zdtDst, zdtStandard); // => -1 + // 1:45 is later than 1:30 when looking at a wall clock + Temporal.PlainTime.compare(zdtDst, zdtStandard); // => 1 + + // Forward transitions will skip clock times. Skipped times will be disambiguated. + const zdtBase = Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]"); + const timeSkipped = Temporal.PlainTime.from("02:30"); + const timeValid = Temporal.PlainTime.from("03:30"); + const zdtSkipped = zdtBase.withPlainTime(timeSkipped); + const zdtValid = zdtBase.withPlainTime(timeValid); + // The skipped time 2:30AM is disambiguated to 3:30AM, so the instants are equal + Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid); // => 0 + // 2:30 is earlier than 3:30 on a wall clock + Temporal.PlainTime.compare(timeSkipped, timeValid); // => -1 + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.hour; // => 19 + time.minute; // => 39 + time.second; // => 9 + time.millisecond; // => 68 + time.microsecond; // => 346 + time.nanosecond; // => 205 + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + // What's the top of the next hour? + time.add({ hours: 1 }).with({ + minute: 0, + second: 0, + millisecond: 0, + microsecond: 0, + nanosecond: 0, + }); // => 20:00:00 + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.add({ minutes: 5, nanoseconds: 800 }); // => 19:44:09.068347005 + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.subtract({ minutes: 5, nanoseconds: 800 }); // => 19:34:09.068345405 + } + + { + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.until(Temporal.PlainTime.from("22:39:09.068346205")); // => PT2H25M48.096948106S + time.until(Temporal.PlainTime.from("19:39:09.068346205")); // => -PT34M11.903051894S + + // Rounding, for example if you don't care about sub-seconds + time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }); + // => PT2H25M48S + } + + { + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.since(Temporal.PlainTime.from("19:39:09.068346205")); // => PT34M11.903051894S + time.since(Temporal.PlainTime.from("22:39:09.068346205")); // => -PT2H25M48.096948106S + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + + // Round to a particular unit + time.round({ smallestUnit: "hour" }); // => 20:00:00 + // Round to an increment of a unit, e.g. half an hour: + time.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 19:30:00 + // Round to the same increment but round up instead: + time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }); + // => 20:00:00 + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + const other = Temporal.PlainTime.from("20:13:20.971398099"); + time.equals(other); // => false + time.equals(time); // => true + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toString(); // => '19:39:09.068346205' + + time.toString({ smallestUnit: "minute" }); // => '19:39' + time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09' + time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683' + time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }); + // => '19:39:09.06835' + } + + { + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toLocaleString(); // example output: '7:39:09 PM' + time.toLocaleString("de-DE"); // example output: '19:39:09' + time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }); // => '19:39:09' + time.toLocaleString("en-US-u-nu-fullwide-hc-h24"); // => '19:39:09' + } + + { + // Leet hour on pi day in 2020 + const datetime = new Temporal.PlainDateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37:00 + } + + { + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30"); + dt = Temporal.PlainDateTime.from("19951207T032430"); + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 1995-12-07T03:24:30 + // same as above; time zone is ignored + dt === Temporal.PlainDateTime.from(dt); // => false + + dt = Temporal.PlainDateTime.from({ + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035 + dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }); // => 1995-12-07T00:00:00 + dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")); + // => 1995-12-07T00:00:00 + // same as above; Temporal.PlainDate has year, month, and day properties + + dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }); + // => 1995-12-07T03:24:30[u-ca=hebrew] + + // Different overflow modes + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }); + // => 2001-01-01T23:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }); + // => 2001-01-01T00:59:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }); + // => throws + } + + { + const one = Temporal.PlainDateTime.from("1995-12-07T03:24"); + const two = Temporal.PlainDateTime.from("1995-12-07T01:24"); + const three = Temporal.PlainDateTime.from("2015-12-07T01:24"); + const sorted = [one, two, three].sort(Temporal.PlainDateTime.compare); + sorted.join(" "); + // => '1995-12-07T01:24:00 1995-12-07T03:24:00 2015-12-07T01:24:00' + } + + { + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 + + dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]"); + dt.year; // => 5779 + dt.month; // => 6 + dt.monthCode; // => 'M05L' + dt.day; // => 18 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 + } + + { + const date = Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1]; // => 'THU' + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + // ISO ordinal date + console.log(dt.year, dt.dayOfYear); // => '1995 341' + } + + { + const dt = Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500"); + // ISO week date + console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek); // => '2021 52 6' + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.daysInWeek; // => 7 + } + + { + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const dt = Temporal.Now.plainDateTimeISO().with({ month }); + monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt); + } + + const strings = monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); + } + + { + const dt = Temporal.Now.plainDateTimeISO(); + const percent = dt.dayOfYear / dt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" + } + + { + const dt = Temporal.PlainDate.from("1900-01-01T12:00"); + dt.monthsInYear; // => 12 + } + + { + // Is this year a leap year? + const dt = Temporal.Now.plainDateTimeISO(); + dt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + dt.with({ year: 2100 }).inLeapYear; // => false + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035 + } + + { + const dt = Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500"); + dt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00 + const time = Temporal.PlainTime.from("11:22"); + dt.withPlainTime(time); // => 2015-12-07T11:22:00 + dt.withPlainTime("12:34"); // => 2015-12-07T12:34:00 + + // easier for chaining + dt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00 + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]"); + dt.withCalendar("iso8601"); // => 1995-12-07T03:24:30.0000035 + } + + { + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.add({ years: 20, months: 4, nanoseconds: 500 }); // => 2016-04-07T03:24:30.000004 + + dt = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt.add({ months: 1 }); // => 2019-02-28T15:30:00 + dt.add({ months: 1 }, { overflow: "reject" }); // => throws + } + + { + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.subtract({ years: 20, months: 4, nanoseconds: 500 }); // => 1975-08-07T03:24:30.000003 + + dt = Temporal.PlainDateTime.from("2019-03-31T15:30"); + dt.subtract({ months: 1 }); // => 2019-02-28T15:30:00 + dt.subtract({ months: 1 }, { overflow: "reject" }); // => throws + } + + { + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.until(dt2); + // => P8456DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + dt2.until(dt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + dt1.until(dt2, { smallestUnit: "second" }); + // => P8456DT12H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })); + jan1.until(feb1); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1); // => P60D + } + + { + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt2.since(dt1); // => P8456DT12H5M29.9999965S + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + + // Round to a particular unit + dt.round({ smallestUnit: "hour" }); // => 1995-12-07T03:00:00 + // Round to an increment of a unit, e.g. half an hour: + dt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00 + // Round to the same increment but round down instead: + dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00 + } + + { + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.equals(dt2); // => false + dt1.equals(dt1); // => true + } + + { + const dt = Temporal.PlainDateTime.from({ + year: 1999, + month: 12, + day: 31, + hour: 23, + minute: 59, + second: 59, + millisecond: 999, + microsecond: 999, + nanosecond: 999, + }); + dt.toString(); // => '1999-12-31T23:59:59.999999999' + + dt.toString({ smallestUnit: "minute" }); // => '1999-12-31T23:59' + dt.toString({ fractionalSecondDigits: 0 }); // => '1999-12-31T23:59:59' + dt.toString({ fractionalSecondDigits: 4 }); // => '1999-12-31T23:59:59.9999' + dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => '2000-01-01T00:00:00.00000000' + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toLocaleString(); // example output: 1995-12-07, 3:24:30 a.m. + dt.toLocaleString("de-DE"); // example output: 7.12.1995, 03:24:30 + dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }); // => 'Donnerstag' + dt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/7/1995, 3:24:30 AM' + } + + { + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toPlainDate(); // => 1995-12-07 + dt.toPlainTime(); // => 03:24:30.0000035 + dt.toPlainDate().toPlainYearMonth(); // => 1995-12 + dt.toPlainDate().toPlainMonthDay(); // => 12-07 + } + + { + // The June 2019 meeting + const ym = new Temporal.PlainYearMonth(2019, 6); + // => 2019-06 + } + + { + let ym: Temporal.PlainYearMonth; + + ym = Temporal.PlainYearMonth.from("2019-06"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]"); + // => 2019-06 + ym === Temporal.PlainYearMonth.from(ym); // => false + + ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }); // => 2019-06 + ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")); + // => 2019-06 + // (same as above; Temporal.PlainDate has year and month properties) + + // Different overflow modes + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }); + // => 2001-12 + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }); + // => throws + } + + { + const one = Temporal.PlainYearMonth.from("2006-08"); + const two = Temporal.PlainYearMonth.from("2015-07"); + const three = Temporal.PlainYearMonth.from("1930-02"); + const sorted = [one, two, three].sort(Temporal.PlainYearMonth.compare); + sorted.join(" "); // => '1930-02 2006-08 2015-07' + } + + { + let ym: Temporal.PlainYearMonth; + + ym = Temporal.PlainYearMonth.from("2019-06"); + ym.year; // => 2019 + ym.month; // => 6 + ym.monthCode; // => 'M06' + + ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]"); + ym.year; // => 5779 + ym.month; // => 6 + ym.monthCode; // => 'M05L' + } + + { + const ym = Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]"); + ym.era; + // => 'bce' + ym.eraYear; + // => 16 + ym.year; + // => -15 + } + + { + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const ym = Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }); + monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym); + } + + const strings = monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); + } + + { + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }); + const percent = ym.daysInMonth / ym.daysInYear; + `${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!`; + // => 'June 2019 was 8% of the year!' + } + + { + const ym = Temporal.PlainYearMonth.from("1900-01"); + ym.monthsInYear; // => 12 + } + + { + // Was June 2019 in a leap year? + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.inLeapYear; // => false + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + ym.with({ year: 2100 }).inLeapYear; // => false + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + // Get December of that year + ym.with({ month: 12 }); // => 2019-12 + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.add({ years: 20, months: 4 }); // => 2039-10 + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.subtract({ years: 20, months: 4 }); // => 1999-02 + } + + { + const ym = Temporal.PlainYearMonth.from("2006-08"); + const other = Temporal.PlainYearMonth.from("2019-06"); + ym.until(other); // => P12Y10M + ym.until(other, { largestUnit: "month" }); // => P154M + other.until(ym, { largestUnit: "month" }); // => -P154M + + // If you really need to calculate the difference between two YearMonths + // in days, you can eliminate the ambiguity by explicitly choosing the + // day of the month (and if applicable, the time of that day) from which + // you want to reckon the difference. For example, using the first of + // the month to calculate a number of days: + ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }); // => P4687D + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.since(other); // => P12Y10M + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.equals(other); // => false + ym.equals(ym); // => true + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toString(); // => '2019-06' + } + + { + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }); + ym.toLocaleString(); // example output: '6/2019' + // Same as above, but explicitly specifying the calendar: + ym.toLocaleString(undefined, { calendar }); + + ym.toLocaleString("de-DE", { calendar }); // example output: '6.2019' + ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }); // => 'Juni 2019' + ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '6/2019' + } + + { + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toPlainDate({ day: 24 }); // => 2019-06-24 + } + + { + let md: Temporal.PlainMonthDay; + + // Pi day + md = new Temporal.PlainMonthDay(3, 14); // => 03-14 + // Leap day + md = new Temporal.PlainMonthDay(2, 29); // => 02-29 + } + + { + let md: Temporal.PlainMonthDay; + + md = Temporal.PlainMonthDay.from("08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("0824"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 08-24 + md === Temporal.PlainMonthDay.from(md); // => false + + md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }); // => 08-24 + md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")); + // => 08-24 + // (same as above; Temporal.PlainDate has month and day properties) + + // Different overflow modes + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }); + // => 12-01 + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }); + // => 01-31 + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }); + // => throws (this year is not a leap year in the ISO 8601 calendar) + + // non-ISO calendars + md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + /* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }); + // => throws (either year or monthCode is required) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // undefined + ~~~~~ +!!! error TS2339: Property 'month' does not exist on type 'PlainMonthDay'. + // (month property is not present in this type; use monthCode instead) + } + + { + let md: Temporal.PlainMonthDay; + + md = Temporal.PlainMonthDay.from("08-24"); + md.monthCode; // => 'M08' + md.day; // => 24 + md.month; // => undefined + ~~~~~ +!!! error TS2339: Property 'month' does not exist on type 'PlainMonthDay'. + // (no `month` property; use `monthCode` instead) + + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // => undefined + ~~~~~ +!!! error TS2339: Property 'month' does not exist on type 'PlainMonthDay'. + // (no `month` property; use `monthCode` instead) + } + + { + const md = Temporal.PlainMonthDay.from("11-15"); + // What's the last day of that month? + md.with({ day: 31 }); // => 11-30 + Temporal.PlainMonthDay.from("02-01").with({ day: 31 }); // => 02-29 + } + + { + const md1 = Temporal.PlainMonthDay.from("02-28"); + const md2 = Temporal.PlainMonthDay.from("02-29"); + md1.equals(md2); // => false + md1.equals("02-29"); // => false + md1.equals({ monthCode: "M02", day: 29 }); // => false + md2.equals(md2); // => true + md2.equals("02-29"); // => true + md2.equals({ monthCode: "M02", day: 29 }); // => true + } + + { + const md = Temporal.PlainMonthDay.from("08-24"); + md.toString(); // => '08-24' + } + + { + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }); + md.toLocaleString(); // example output: '8/24' + // Same as above, but explicitly specifying the calendar: + md.toLocaleString(undefined, { calendar }); // example output: '8/24' + + md.toLocaleString("de-DE", { calendar }); // => '24.8.' + md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }); // => '24. August' + md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '8/24' + } + + { + const md = Temporal.PlainMonthDay.from({ + calendar: "japanese", + monthCode: "M01", + day: 1, + }); + + const date = md.toPlainDate({ era: "reiwa", eraYear: 2 }); // => 2020-01-01[u-ca=japanese] + } + + { + new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); // => P1Y2M3W4DT5H6M7.987654321S + new Temporal.Duration(0, 0, 0, 40); // => P40D + new Temporal.Duration(undefined, undefined, undefined, 40); // => P40D + new Temporal.Duration(); // => PT0S + } + + { + let d: Temporal.Duration; + + d = Temporal.Duration.from({ years: 1, days: 1 }); // => P1Y1D + d = Temporal.Duration.from({ days: -2, hours: -12 }); // => -P2DT12H + + Temporal.Duration.from(d) === d; // => false + + d = Temporal.Duration.from("P1Y1D"); // => P1Y1D + d = Temporal.Duration.from("-P2DT12H"); // => -P2DT12H + d = Temporal.Duration.from("P0D"); // => PT0S + } + + { + const one = Temporal.Duration.from({ hours: 79, minutes: 10 }); + const two = Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }); + const three = Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }); + const sorted1 = [one, two, three].sort(Temporal.Duration.compare); + sorted1.join(" "); + // => 'P3DT6H50M PT79H10M P3DT7H630S' + + // Sorting relative to a date, taking DST changes into account: + const relativeTo = Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]"); + const sorted2 = [one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })); + sorted2.join(" "); + // => 'PT79H10M P3DT6H50M P3DT7H630S' + } + + { + const d = Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S"); + d.years; // => 1 + d.months; // => 2 + d.weeks; // => 3 + d.days; // => 4 + d.hours; // => 5 + d.minutes; // => 6 + d.seconds; // => 7 + d.milliseconds; // => 987 + d.microseconds; // => 654 + d.nanoseconds; // => 321 + } + + { + let d: Temporal.Duration; + + d = Temporal.Duration.from("PT0S"); + d.blank; // => true + + d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }); + d.blank; // => true + } + + { + let duration: Temporal.Duration; + + duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }); + // Perform a balance operation using additional ISO 8601 calendar rules: + let { years, months } = duration; + years += Math.floor(months / 12); + months %= 12; + duration = duration.with({ years, months }); + // => P4Y2M50DT50H100M + } + + { + const hour = Temporal.Duration.from("PT1H"); + hour.add({ minutes: 30 }); // => PT1H30M + + // Examples of balancing: + const one = Temporal.Duration.from({ hours: 1, minutes: 30 }); + const two = Temporal.Duration.from({ hours: 2, minutes: 45 }); + const result = one.add(two); // => PT4H15M + + // Example of adding calendar units + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 16 }); + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2000-12-01"); + startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P3M4D + + const startDate2 = Temporal.PlainDate.from("2001-01-01"); + startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P3M1D + } + + { + const hourAndAHalf = Temporal.Duration.from("PT1H30M"); + hourAndAHalf.subtract({ hours: 1 }); // => PT30M + + const one = Temporal.Duration.from({ minutes: 180 }); + const two = Temporal.Duration.from({ seconds: 30 }); + one.subtract(two); // => PT179M30S + one.subtract(two).round({ largestUnit: "hour" }); // => PT2H59M30S + + // Example of subtracting calendar units; cannot be subtracted using + // subtract() because units need to be converted + const threeMonths = Temporal.Duration.from({ months: 3 }); + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 15 }); + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2001-01-01"); + startDate1.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P1M13D + + const startDate2 = Temporal.PlainDate.from("2001-02-01"); + startDate2.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P1M16D + } + + { + const d = Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S"); + d.sign; // 1 + d.negated(); // -P1Y2M3DT4H5M6.987654321S + d.negated().sign; // -1 + } + + { + const d = Temporal.Duration.from("-PT8H30M"); + d.abs(); // PT8H30M + } + + { + let d: Temporal.Duration; + + // Balance a duration as far as possible without knowing a starting point + d = Temporal.Duration.from({ minutes: 130 }); + d.round({ largestUnit: "day" }); // => PT2H10M + + // Round to the nearest unit + d = Temporal.Duration.from({ minutes: 10, seconds: 52 }); + d.round({ smallestUnit: "minute" }); // => PT11M + d.round({ smallestUnit: "minute", roundingMode: "trunc" }); // => PT10M + + // How many seconds in a multi-unit duration? + d = Temporal.Duration.from("PT2H34M18S"); + d.round({ largestUnit: "second" }).seconds; // => 9258 + + // Normalize, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.round({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + largestUnit: "year", + }); // => P114DT21H + // (one hour longer because DST skipped an hour) + d.round({ + relativeTo: "2020-01-01", + largestUnit: "year", + }); // => P114DT20H + // (one hour shorter if ignoring DST) + + // Normalize days into months or years + d = Temporal.Duration.from({ days: 190 }); + const refDate = Temporal.PlainDate.from("2020-01-01"); + d.round({ relativeTo: refDate, largestUnit: "year" }); // => P6M8D + + // Same, but in a different calendar system + d.round({ + relativeTo: refDate.withCalendar("hebrew"), + largestUnit: "year", + }); // => P6M13D + + // Round a duration up to the next 5-minute billing period + d = Temporal.Duration.from({ minutes: 6 }); + d.round({ + smallestUnit: "minute", + roundingIncrement: 5, + roundingMode: "ceil", + }); // => PT10M + + // How many full 3-month quarters of this year, are in this duration? + d = Temporal.Duration.from({ months: 10, days: 15 }); + d = d.round({ + smallestUnit: "month", + roundingIncrement: 3, + roundingMode: "trunc", + relativeTo: Temporal.Now.plainDateISO(), + }); + const quarters = d.months / 3; + quarters; // => 3 + } + + { + let d: Temporal.Duration; + + // How many seconds in 130 hours and 20 minutes? + d = Temporal.Duration.from({ hours: 130, minutes: 20 }); + d.total({ unit: "second" }); // => 469200 + + // How many 24-hour days is 123456789 seconds? + d = Temporal.Duration.from("PT123456789S"); + d.total({ unit: "day" }); // 1428.8980208333332 + + // Find totals in months, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.total({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + unit: "month", + }); // => 3.7958333333333334 + d.total({ + unit: "month", + relativeTo: "2020-01-01", + }); // => 3.7944444444444443 + } + + { + let d: Temporal.Duration; + + d = Temporal.Duration.from({ years: 1, days: 1 }); + d.toString(); // => P1Y1D + d = Temporal.Duration.from({ years: -1, days: -1 }); + d.toString(); // => -P1Y1D + d = Temporal.Duration.from({ milliseconds: 1000 }); + d.toString(); // => PT1S + + // The output format always balances units under 1 s, even if the + // underlying Temporal.Duration object doesn't. + const nobal = Temporal.Duration.from({ milliseconds: 3500 }); + console.log(`${nobal}`, nobal.seconds, nobal.milliseconds); // => 'PT3.5S 0 3500' + const bal = nobal.round({ largestUnit: "year" }); // balance through round + console.log(`${bal}`, bal.seconds, bal.milliseconds); // => 'PT3.5S 3 500' + + d = Temporal.Duration.from("PT59.999999999S"); + d.toString({ smallestUnit: "second" }); // => PT59S + d.toString({ fractionalSecondDigits: 0 }); // => PT59S + d.toString({ fractionalSecondDigits: 4 }); // => PT59.9999S + d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => PT60.00000000S + } + + { + const d = Temporal.Duration.from("P1DT6H30M"); + d.toLocaleString(); // example output: '1 day 6 hours 30 minutes' + d.toLocaleString("de-DE"); // example output: '1 Tag 6 Stunden 30 Minuten' + d.toLocaleString("en-US", { days: "short", hours: "numeric" }); // example output: '1 day 6 hours' + } + + { + Temporal.Now.instant(); // get the current system exact time + Temporal.Now.timeZoneId(); // get the current system time zone + Temporal.Now.zonedDateTimeISO(); // get the current date and wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateISO(); // get the current date in the system time zone and ISO-8601 calendar + Temporal.Now.plainTimeISO(); // get the current wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateTimeISO(); // same as above, but return the DateTime in the ISO-8601 calendar + } + \ No newline at end of file diff --git a/tests/baselines/reference/temporal.js b/tests/baselines/reference/temporal.js new file mode 100644 index 0000000000000..5e88e5df300f3 --- /dev/null +++ b/tests/baselines/reference/temporal.js @@ -0,0 +1,3369 @@ +//// [tests/cases/compiler/temporal.ts] //// + +//// [temporal.ts] +/** + * Test cases derived from documentation at tc39/proposal-temporal, + * under the following license: + * + * Copyright 2017, 2018, 2019, 2020 ECMA International + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +{ + const instant = Temporal.Instant.from("2020-01-01T00:00+05:30"); // => 2019-12-31T18:30:00Z + instant.epochNanoseconds; // => 1577817000000000000n + + // `Temporal.Instant` lacks properties that depend on time zone or calendar + instant.year; // => undefined + + const zdtTokyo = instant.toZonedDateTimeISO("Asia/Tokyo"); // => 2020-01-01T03:30:00+09:00[Asia/Tokyo] + zdtTokyo.year; // => 2020 + zdtTokyo.toPlainDate(); // => 2020-01-01 +} + +{ + // Convert from `Temporal.Instant` to `Date` (which uses millisecond precision) + const instant = Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30"); + // => 2019-12-31T18:30:00.123456789Z + const date = new Date(instant.epochMilliseconds); + date.toISOString(); // => 2019-12-31T18:30:00.123Z + + // Convert from `Date` to `Temporal.Instant` + const sameInstant = date.toTemporalInstant(); // => 2019-12-31T18:30:00.123Z +} + +{ + const date = new Date(2019, 11, 31, 18, 30); // => Tue Dec 31 2019 18:30:00 GMT-0800 (Pacific Standard Time) + const instant = date.toTemporalInstant(); // => 2020-01-01T02:30:00Z + const zonedDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()); + // => 2019-12-31T18:30:00-08:00[America/Los_Angeles] + zonedDateTime.day; // => 31 + const dateOnly = zonedDateTime.toPlainDate(); // => 2019-12-31 +} + +{ + const instant = new Temporal.Instant(1553906700000000000n); + // When was the Unix epoch? + const epoch = new Temporal.Instant(0n); // => 1970-01-01T00:00:00Z + // Dates before the Unix epoch are negative + const turnOfTheCentury = new Temporal.Instant(-2208988800000000000n); // => 1900-01-01T00:00:00Z +} + +{ + let instant: Temporal.Instant; + instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]"); + instant = Temporal.Instant.from("2019-03-30T01:45+01:00"); + instant = Temporal.Instant.from("2019-03-30T00:45Z"); + instant === Temporal.Instant.from(instant); // => false +} + +{ + const legacyDate = new Date("1995-12-17T03:24Z"); + let instant: Temporal.Instant; + instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()); // => 1995-12-17T03:24:00Z + instant = legacyDate.toTemporalInstant(); // recommended +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + const three = Temporal.Instant.fromEpochMilliseconds(1.2e12); + const sorted = [three, one, two].sort(Temporal.Instant.compare); + sorted.join(" "); + // => '2001-09-09T01:46:40Z 2004-11-09T11:33:20Z 2008-01-10T21:20:00Z' +} + +{ + const instant = Temporal.Instant.from("2019-03-30T00:45Z"); + new Date(instant.epochMilliseconds); // => 2019-03-30T00:45:00.000Z + + // If you need epoch seconds data: + const epochSecs = Math.floor(instant.epochMilliseconds / 1000); // => 1553906700 + + const ns = instant.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +} + +{ + // Converting a specific exact time to a calendar date / wall-clock time + let timestamp: Temporal.Instant; + timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100_000); + timestamp.toZonedDateTimeISO("Europe/Berlin"); // => 2019-03-31T01:45:00+01:00[Europe/Berlin] + timestamp.toZonedDateTimeISO("UTC"); // => 2019-03-31T00:45:00+00:00[UTC] + timestamp.toZonedDateTimeISO("-08:00"); // => 2019-03-30T16:45:00-08:00[-08:00] + + // What time was the Unix epoch (timestamp 0) in Bell Labs (Murray Hill, New Jersey, USA) in the Gregorian calendar? + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory"); + // => 1969-12-31T19:00:00-05:00[America/New_York][u-ca=gregory] + + // What time was the Unix epoch in Tokyo in the Japanese calendar? + const zdt = epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese"); + // => 1970-01-01T09:00:00+09:00[Asia/Tokyo][u-ca=japanese] + console.log(zdt.eraYear, zdt.era); + // => '45 showa' +} + +{ + // Temporal.Instant representing five hours from now + Temporal.Now.instant().add({ hours: 5 }); + const fiveHours = Temporal.Duration.from({ hours: 5 }); + Temporal.Now.instant().add(fiveHours); +} + +{ + // Temporal.Instant representing this time an hour ago + Temporal.Now.instant().subtract({ hours: 1 }); + const oneHour = Temporal.Duration.from({ hours: 1 }); + Temporal.Now.instant().subtract(oneHour); +} + +{ + const startOfMoonMission = Temporal.Instant.from("1969-07-16T13:32:00Z"); + const endOfMoonMission = Temporal.Instant.from("1969-07-24T16:50:35Z"); + const missionLength = startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }); + // => PT195H18M35S + missionLength.toLocaleString(); + // example output: '195 hours 18 minutes 35 seconds' + + // Rounding, for example if you don't care about the minutes and seconds + const approxMissionLength = startOfMoonMission.until(endOfMoonMission, { + largestUnit: "hour", + smallestUnit: "hour", + }); + // => PT195H + + // A billion (10^9) seconds since the epoch in different units + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + const billion = Temporal.Instant.fromEpochMilliseconds(1e9); + epoch.until(billion); + // => PT1000000000S + epoch.until(billion, { largestUnit: "hour" }); + // => PT277777H46M40S + const ns = epoch.until(billion, { largestUnit: "nanosecond" }); + // => PT1000000000S + ns.add({ nanoseconds: 1 }); + // => PT1000000000S + // (lost precision) + + // Calculate the difference in years, eliminating the ambiguity by + // explicitly using the corresponding calendar date in UTC: + epoch.toZonedDateTimeISO("UTC").until( + billion.toZonedDateTimeISO("UTC"), + { largestUnit: "year" }, + ); + // => P31Y8M8DT1H46M40S +} + +{ + const instant = Temporal.Instant.from("2019-03-30T02:45:59.999999999Z"); + + // Round to a particular unit + instant.round({ smallestUnit: "second" }); // => 2019-03-30T02:46:00Z + // Round to an increment of a unit, e.g. an hour: + instant.round({ roundingIncrement: 60, smallestUnit: "minute" }); + // => 2019-03-30T03:00:00Z + // Round to the same increment but round down instead: + instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }); + // => 2019-03-30T02:00:00Z +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + one.equals(two); // => false + one.equals(one); // => true +} + +{ + const instant = Temporal.Instant.fromEpochMilliseconds(1574074321816); + instant.toString(); // => '2019-11-18T10:52:01.816Z' + instant.toString({ timeZone: "UTC" }); + // => '2019-11-18T10:52:01.816+00:00' + instant.toString({ timeZone: "Asia/Seoul" }); + // => '2019-11-18T19:52:01.816+09:00' + + instant.toString({ smallestUnit: "minute" }); + // => '2019-11-18T10:52Z' + instant.toString({ fractionalSecondDigits: 0 }); + // => '2019-11-18T10:52:01Z' + instant.toString({ fractionalSecondDigits: 4 }); + // => '2019-11-18T10:52:01.8160Z' + instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }); + // => '2019-11-18T10:52:02Z' +} + +{ + const instant = Temporal.Instant.from("2019-11-18T11:00:00.000Z"); + instant.toLocaleString(); // example output: '2019-11-18, 3:00:00 a.m.' + instant.toLocaleString("de-DE"); // example output: '18.11.2019, 03:00:00' + instant.toLocaleString("de-DE", { + timeZone: "Europe/Berlin", + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + timeZoneName: "long", + }); // => '18.11.2019, 12:00 Mitteleuropäische Normalzeit' + instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { + timeZone: "Asia/Kolkata", + }); // => '11/18/2019, 4:30:00 PM' +} + +{ + // UNIX epoch in California + new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + // same, but shorter +} + +{ + let zdt: Temporal.ZonedDateTime; + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); + zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); + + zdt = Temporal.ZonedDateTime.from({ + timeZone: "America/Los_Angeles", + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] + + // Different overflow modes + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00+01:00[Europe/Paris] + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws RangeError +} + +{ + const arr = [ + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), + ]; + const sorted = arr.sort(Temporal.ZonedDateTime.compare); + JSON.stringify(sorted, undefined, 2); + // => + // '[ + // "2020-02-01T12:30+01:00[Europe/Brussels]", + // "2020-02-01T12:30+00:00[Europe/London]", + // "2020-02-01T12:30-05:00[America/Toronto]", + // "2020-02-01T12:30-05:00[America/New_York]" + // ]' +} + +{ + const dt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]"); + const epochMs = zdt.epochMilliseconds; + // => 1580527800000 + zdt.toInstant().epochMilliseconds; + // => 1580527800000 + const legacyDate = new Date(epochMs); + // => 2020-02-01T03:30:00.000Z + // (if the system time zone is America/Los_Angeles) + const epochNanos = zdt.epochNanoseconds; + // => 1580527800000000000n + + // If you need epoch seconds data: + const epochSecs = Math.floor(zdt.epochMilliseconds / 1000); // => 1553906700 + // => 1580527800 + + // If you need epoch microseconds data: + // (Note the extra check for correct floor rounding with bigints) + const ns = zdt.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); + // => 1580527800000000n +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + `Time zone is: ${zdt.timeZoneId}`; + // => 'Time zone is: America/Los_Angeles' + zdt.withTimeZone("Asia/Kolkata").timeZoneId; + // => Asia/Kolkata + zdt.withTimeZone("Asia/Calcutta").timeZoneId; + // => Asia/Calcutta (does not follow links in the IANA Time Zone Database) + + zdt.withTimeZone("europe/paris").timeZoneId; + // => Europe/Paris (normalized to match IANA Time Zone Database capitalization) + + zdt.withTimeZone("+05:00").timeZoneId; + // => +05:00 + zdt.withTimeZone("+05").timeZoneId; + // => +05:00 (normalized to ±HH:MM) + zdt.withTimeZone("+0500").timeZoneId; + // => +05:00 (normalized to ±HH:MM) +} + +{ + const date = Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1]; // => 'THU' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + // ISO ordinal date + console.log(zdt.year, zdt.dayOfYear); // => '1995 341' +} + +{ + const zdt = Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]"); + // ISO week date + console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek); // => '2021 52 6' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + zdt.daysInWeek; // => 7 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const zdt = Temporal.Now.zonedDateTimeISO().with({ month }); + monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt); + } + + const strings = monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const zdt = Temporal.Now.zonedDateTimeISO(); + const percent = zdt.dayOfYear / zdt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} + +{ + const zdt = Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]"); + zdt.monthsInYear; // => 12 +} + +{ + // Is this year a leap year? + const zdt = Temporal.Now.zonedDateTimeISO(); + zdt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + zdt.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const zdt = Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]"); + zdt.hoursInDay; // 25 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offsetNanoseconds; + // => -25200000000000 + // (-7 * 3600 * 1e9) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offset; + // => '-07:00' + zdt.withTimeZone("Asia/Kolkata").offset; + // => '+05:30' + + const minus8Hours = "-08:00"; + const daylightTime0130 = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + // => 2020-11-01T01:30:00-07:00[America/Los_Angeles] + // This is Pacific Daylight Time 1:30AM + const repeated0130 = daylightTime0130.with({ offset: minus8Hours }); + // => 2020-11-01T01:30:00-08:00[America/Los_Angeles] + // This is Pacific Standard Time 1:30AM +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]"); + zdt.with({ year: 2015, minute: 31 }); // => 2015-12-07T03:31:00-06:00[America/Chicago] +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + zdt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00-08:00[America/Los_Angeles] + const time = Temporal.PlainTime.from("11:22"); + zdt.withPlainTime(time); // => 2015-12-07T11:22:00-08:00[America/Los_Angeles] + zdt.withPlainTime("12:34"); // => 2015-12-07T12:34:00-08:00[America/Los_Angeles] + + // easier for chaining + zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00-08:00[America/Los_Angeles] +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]"); + zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]' + zdt.withTimeZone("Africa/Accra").toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]"); + `${zdt.era} ${zdt.eraYear}`; // => 'heisei 7' + zdt.withCalendar("gregory").eraYear; // => 1995 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const laterDay = zdt.add({ days: 1 }); + // => 2020-03-09T00:00:00-07:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + laterDay.since(zdt, { largestUnit: "hour" }).hours; + // => 23 + // because one clock hour lost to DST + + const laterHours = zdt.add({ hours: 24 }); + // => 2020-03-09T01:00:00-07:00[America/Los_Angeles] + // Adding time units doesn't adjust for DST. Result is 1:00AM: 24 real-world + // hours later because a clock hour was skipped by DST. + laterHours.since(zdt, { largestUnit: "hour" }).hours; // => 24 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const earlierDay = zdt.subtract({ days: 1 }); + // => 2020-03-08T00:00:00-08:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + earlierDay.since(zdt, { largestUnit: "hour" }).hours; + // => -23 + // because one clock hour lost to DST + + const earlierHours = zdt.subtract({ hours: 24 }); + // => 2020-03-07T23:00:00-08:00[America/Los_Angeles] + // Subtracting time units doesn't adjust for DST. Result is 11:00PM: 24 real-world + // hours earlier because a clock hour was skipped by DST. + earlierHours.since(zdt, { largestUnit: "hour" }).hours; // => -24 +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt1.until(zdt2); + // => PT202956H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + zdt2.until(zdt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + zdt1.until(zdt2, { smallestUnit: "second" }); + // => PT202956H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })); + jan1.until(feb1, { largestUnit: "day" }); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1, { largestUnit: "day" }); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1, { largestUnit: "day" }); // => P60D +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt2.since(zdt1); // => PT202956H5M29.9999965S +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + + // Round to a particular unit + zdt.round({ smallestUnit: "hour" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + // Round to an increment of a unit, e.g. half an hour: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00-08:00[America/Los_Angeles] + // Round to the same increment but round down instead: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); + zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] +} + +{ + let duration: Temporal.Duration; + // How long until the next offset change from now, in the current location? + const tz = Temporal.Now.timeZoneId(); + const now = Temporal.Now.zonedDateTimeISO(tz); + const nextTransition = now.getTimeZoneTransition("next"); + duration = nextTransition!.since(now); + duration.toLocaleString(); // output will vary + + // How long until the previous offset change from now, in the current location? + const previousTransition = now.getTimeZoneTransition("previous"); + duration = now.since(previousTransition!); + duration.toLocaleString(); // output will vary +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]"); + const zdt2 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]"); + zdt1.equals(zdt2); // => false (same offset but different time zones) + zdt1.equals(zdt1); // => true + + // To compare time zone IDs, use withTimeZone() with each ID on the same + // ZonedDateTime instance, and use equals() to compare + const kolkata = zdt1.withTimeZone("Asia/Kolkata"); + kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")); // => true + + // Offset time zones are never equivalent to named time zones + kolkata.equals(zdt1.withTimeZone("+05:30")); // => false + const zeroOffset = zdt1.withTimeZone("+00:00"); + zeroOffset.equals(zdt1.withTimeZone("UTC")); // => false + + // For offset time zones, any valid format is accepted + zeroOffset.equals(zdt1.withTimeZone("+00:00")); // => true + zeroOffset.equals(zdt1.withTimeZone("+0000")); // => true + zeroOffset.equals(zdt1.withTimeZone("+00")); // => true +} + +{ + let zdt: Temporal.ZonedDateTime; + zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos]' + zdt = zdt.withCalendar("japanese"); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos][u-ca=japanese]' +} + +{ + const zdt = Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]"); + zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM + zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' + const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; + zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' + /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); + // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin + zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' + zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]"); + zdt.toInstant(); // => 1995-12-07T01:24:30Z + zdt.toPlainDateTime(); // => 1995-12-07T03:24:30 + zdt.toPlainDate(); // => 1995-12-07 + zdt.toPlainTime(); // => 03:24:30 + zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 + zdt.toPlainDate().toPlainMonthDay(); // => 12-07 +} + +{ + // Pi day in 2020 + const date = new Temporal.PlainDate(2020, 3, 14); // => 2020-03-14 +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); // => 2006-08-24 + date = Temporal.PlainDate.from("20060824"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 2006-08-24 + date === Temporal.PlainDate.from(date); // => false + + date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24 + date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")); + // => 2006-08-24 + // same as above; Temporal.PlainDateTime has year, month, and day properties + + date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }); + // => 2006-08-24[u-ca=islamic] + + // Different overflow modes + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01 + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31 + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainDate.from("2006-08-24"); + const two = Temporal.PlainDate.from("2015-07-14"); + const three = Temporal.PlainDate.from("1930-02-18"); + const sorted = [one, two, three].sort(Temporal.PlainDate.compare); + sorted.join(" "); // => '1930-02-18 2006-08-24 2015-07-14' +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.year; // => 2006 + date.month; // => 8 + date.monthCode; // => 'M08' + date.day; // => 24 + + date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]"); + date.year; // => 5779 + date.month; // => 6 + date.monthCode; // => 'M05L' + date.day; // => 18 +} + +{ + const date = Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1]; // => 'THU' +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + // ISO ordinal date + console.log(date.year, date.dayOfYear); // => '2006 236' +} + +{ + const date = Temporal.PlainDate.from("2022-01-01"); + // ISO week date + console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek); // => '2021 52 6' +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.daysInWeek; // => 7 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const date = Temporal.Now.plainDateISO().with({ month }); + monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date); + } + + const strings = monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const date = Temporal.Now.plainDateISO(); + const percent = date.dayOfYear / date.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} + +{ + const date = Temporal.PlainDate.from("1900-01-01"); + date.monthsInYear; // => 12 +} + +{ + // Is this year a leap year? + const date = Temporal.Now.plainDateISO(); + date.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + date.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const date = Temporal.PlainDate.from("2006-01-24"); + // What's the first day of this month? + date.with({ day: 1 }); // => 2006-01-01 + // What's the last day of the next month? + const nextMonthDate = date.add({ months: 1 }); + nextMonthDate.with({ day: nextMonthDate.daysInMonth }); // => 2006-02-28 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24[u-ca=japanese]"); + date.withCalendar("iso8601"); // => 2006-08-24 +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.add({ years: 20, months: 4 }); // => 2026-12-24 + + date = Temporal.PlainDate.from("2019-01-31"); + date.add({ months: 1 }); // => 2019-02-28 + date.add({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.subtract({ years: 20, months: 4 }); // => 1986-04-24 + + date = Temporal.PlainDate.from("2019-03-31"); + date.subtract({ months: 1 }); // => 2019-02-28 + date.subtract({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + earlier.until(later); // => P4543D + earlier.until(later, { largestUnit: "year" }); // => P12Y5M7D + later.until(earlier, { largestUnit: "year" }); // => -P12Y5M7D + + // If you really need to calculate the difference between two Dates in + // hours, you can eliminate the ambiguity by explicitly choosing the + // point in time from which you want to reckon the difference. For + // example, using noon: + const noon = Temporal.PlainTime.from("12:00"); + earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }); + // => PT109032H + + const newyear = Temporal.PlainDate.from("2020-01-01"); + newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S + newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S (mid-month dates rounded down to match `Temporal.PlainDateTime` behavior) + newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT1M +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + later.since(earlier); // => P4543D +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + const other = Temporal.PlainDate.from("2019-01-31"); + date.equals(other); // => false + date.equals(date); // => true +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toString(); // => '2006-08-24' +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toLocaleString(); // example output: 8/24/2006 + date.toLocaleString("de-DE"); // example output: '24.8.2006' + date.toLocaleString("de-DE", { weekday: "long" }); // => 'Donnerstag' + date.toLocaleString("en-US-u-nu-fullwide"); // => '8/24/2006' +} + +{ + const plainDate = Temporal.PlainDate.from("2006-08-24"); + const plainTime = Temporal.PlainTime.from("15:23:30.003"); + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }); + // => 2006-08-24T15:23:30.003-07:00[America/Los_Angeles] + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }); + // => 2006-08-24T00:00:00-07:00[America/Los_Angeles] +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + const time = Temporal.PlainTime.from("15:23:30.003"); + date.toPlainDateTime(time); // => 2006-08-24T15:23:30.003 + date.toPlainDateTime(); // => 2006-08-24T00:00:00 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toPlainYearMonth(); // => 2006-08 + date.toPlainMonthDay(); // => 08-24 +} + +{ + // Leet hour + const time = new Temporal.PlainTime(13, 37); // => 13:37:00 +} + +{ + let time: Temporal.PlainTime; + + time = Temporal.PlainTime.from("03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("032430"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 03:24:30 + // (same as above; time zone is ignored) + time === Temporal.PlainTime.from(time); // => false + + time = Temporal.PlainTime.from({ + hour: 19, + minute: 39, + second: 9, + millisecond: 68, + microsecond: 346, + nanosecond: 205, + }); // => 19:39:09.068346205 + time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }); // => 19:39:09 + time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")); + // => 19:39:09 + // (same as above; Temporal.PlainDateTime has hour, minute, etc. properties) + + // Different overflow modes + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }); + // => 15:59:00 + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }); + // => 15:00:00 + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }); + // => throws + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainTime.from("03:24"); + const two = Temporal.PlainTime.from("01:24"); + const three = Temporal.PlainTime.from("01:24:05"); + const sorted = [one, two, three].sort(Temporal.PlainTime.compare); + sorted.join(" "); // => '01:24:00 01:24:05 03:24:00' +} + +{ + // Backward transitions will repeat clock times + const zdtDst = Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]"); + const zdtStandard = Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]"); + // The "first" 1:45 (in Daylight Time) is earlier than the "second" 1:30 (in Standard Time) + Temporal.ZonedDateTime.compare(zdtDst, zdtStandard); // => -1 + // 1:45 is later than 1:30 when looking at a wall clock + Temporal.PlainTime.compare(zdtDst, zdtStandard); // => 1 + + // Forward transitions will skip clock times. Skipped times will be disambiguated. + const zdtBase = Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]"); + const timeSkipped = Temporal.PlainTime.from("02:30"); + const timeValid = Temporal.PlainTime.from("03:30"); + const zdtSkipped = zdtBase.withPlainTime(timeSkipped); + const zdtValid = zdtBase.withPlainTime(timeValid); + // The skipped time 2:30AM is disambiguated to 3:30AM, so the instants are equal + Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid); // => 0 + // 2:30 is earlier than 3:30 on a wall clock + Temporal.PlainTime.compare(timeSkipped, timeValid); // => -1 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.hour; // => 19 + time.minute; // => 39 + time.second; // => 9 + time.millisecond; // => 68 + time.microsecond; // => 346 + time.nanosecond; // => 205 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + // What's the top of the next hour? + time.add({ hours: 1 }).with({ + minute: 0, + second: 0, + millisecond: 0, + microsecond: 0, + nanosecond: 0, + }); // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.add({ minutes: 5, nanoseconds: 800 }); // => 19:44:09.068347005 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.subtract({ minutes: 5, nanoseconds: 800 }); // => 19:34:09.068345405 +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.until(Temporal.PlainTime.from("22:39:09.068346205")); // => PT2H25M48.096948106S + time.until(Temporal.PlainTime.from("19:39:09.068346205")); // => -PT34M11.903051894S + + // Rounding, for example if you don't care about sub-seconds + time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }); + // => PT2H25M48S +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.since(Temporal.PlainTime.from("19:39:09.068346205")); // => PT34M11.903051894S + time.since(Temporal.PlainTime.from("22:39:09.068346205")); // => -PT2H25M48.096948106S +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + + // Round to a particular unit + time.round({ smallestUnit: "hour" }); // => 20:00:00 + // Round to an increment of a unit, e.g. half an hour: + time.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 19:30:00 + // Round to the same increment but round up instead: + time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }); + // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + const other = Temporal.PlainTime.from("20:13:20.971398099"); + time.equals(other); // => false + time.equals(time); // => true +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toString(); // => '19:39:09.068346205' + + time.toString({ smallestUnit: "minute" }); // => '19:39' + time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09' + time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683' + time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }); + // => '19:39:09.06835' +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toLocaleString(); // example output: '7:39:09 PM' + time.toLocaleString("de-DE"); // example output: '19:39:09' + time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }); // => '19:39:09' + time.toLocaleString("en-US-u-nu-fullwide-hc-h24"); // => '19:39:09' +} + +{ + // Leet hour on pi day in 2020 + const datetime = new Temporal.PlainDateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37:00 +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30"); + dt = Temporal.PlainDateTime.from("19951207T032430"); + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 1995-12-07T03:24:30 + // same as above; time zone is ignored + dt === Temporal.PlainDateTime.from(dt); // => false + + dt = Temporal.PlainDateTime.from({ + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035 + dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }); // => 1995-12-07T00:00:00 + dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")); + // => 1995-12-07T00:00:00 + // same as above; Temporal.PlainDate has year, month, and day properties + + dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }); + // => 1995-12-07T03:24:30[u-ca=hebrew] + + // Different overflow modes + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }); + // => 2001-01-01T23:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }); + // => 2001-01-01T00:59:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainDateTime.from("1995-12-07T03:24"); + const two = Temporal.PlainDateTime.from("1995-12-07T01:24"); + const three = Temporal.PlainDateTime.from("2015-12-07T01:24"); + const sorted = [one, two, three].sort(Temporal.PlainDateTime.compare); + sorted.join(" "); + // => '1995-12-07T01:24:00 1995-12-07T03:24:00 2015-12-07T01:24:00' +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 + + dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]"); + dt.year; // => 5779 + dt.month; // => 6 + dt.monthCode; // => 'M05L' + dt.day; // => 18 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 +} + +{ + const date = Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1]; // => 'THU' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + // ISO ordinal date + console.log(dt.year, dt.dayOfYear); // => '1995 341' +} + +{ + const dt = Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500"); + // ISO week date + console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek); // => '2021 52 6' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.daysInWeek; // => 7 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const dt = Temporal.Now.plainDateTimeISO().with({ month }); + monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt); + } + + const strings = monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const dt = Temporal.Now.plainDateTimeISO(); + const percent = dt.dayOfYear / dt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} + +{ + const dt = Temporal.PlainDate.from("1900-01-01T12:00"); + dt.monthsInYear; // => 12 +} + +{ + // Is this year a leap year? + const dt = Temporal.Now.plainDateTimeISO(); + dt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + dt.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035 +} + +{ + const dt = Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500"); + dt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00 + const time = Temporal.PlainTime.from("11:22"); + dt.withPlainTime(time); // => 2015-12-07T11:22:00 + dt.withPlainTime("12:34"); // => 2015-12-07T12:34:00 + + // easier for chaining + dt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00 +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]"); + dt.withCalendar("iso8601"); // => 1995-12-07T03:24:30.0000035 +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.add({ years: 20, months: 4, nanoseconds: 500 }); // => 2016-04-07T03:24:30.000004 + + dt = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt.add({ months: 1 }); // => 2019-02-28T15:30:00 + dt.add({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.subtract({ years: 20, months: 4, nanoseconds: 500 }); // => 1975-08-07T03:24:30.000003 + + dt = Temporal.PlainDateTime.from("2019-03-31T15:30"); + dt.subtract({ months: 1 }); // => 2019-02-28T15:30:00 + dt.subtract({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.until(dt2); + // => P8456DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + dt2.until(dt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + dt1.until(dt2, { smallestUnit: "second" }); + // => P8456DT12H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })); + jan1.until(feb1); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1); // => P60D +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt2.since(dt1); // => P8456DT12H5M29.9999965S +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + + // Round to a particular unit + dt.round({ smallestUnit: "hour" }); // => 1995-12-07T03:00:00 + // Round to an increment of a unit, e.g. half an hour: + dt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00 + // Round to the same increment but round down instead: + dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00 +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.equals(dt2); // => false + dt1.equals(dt1); // => true +} + +{ + const dt = Temporal.PlainDateTime.from({ + year: 1999, + month: 12, + day: 31, + hour: 23, + minute: 59, + second: 59, + millisecond: 999, + microsecond: 999, + nanosecond: 999, + }); + dt.toString(); // => '1999-12-31T23:59:59.999999999' + + dt.toString({ smallestUnit: "minute" }); // => '1999-12-31T23:59' + dt.toString({ fractionalSecondDigits: 0 }); // => '1999-12-31T23:59:59' + dt.toString({ fractionalSecondDigits: 4 }); // => '1999-12-31T23:59:59.9999' + dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => '2000-01-01T00:00:00.00000000' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toLocaleString(); // example output: 1995-12-07, 3:24:30 a.m. + dt.toLocaleString("de-DE"); // example output: 7.12.1995, 03:24:30 + dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }); // => 'Donnerstag' + dt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/7/1995, 3:24:30 AM' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toPlainDate(); // => 1995-12-07 + dt.toPlainTime(); // => 03:24:30.0000035 + dt.toPlainDate().toPlainYearMonth(); // => 1995-12 + dt.toPlainDate().toPlainMonthDay(); // => 12-07 +} + +{ + // The June 2019 meeting + const ym = new Temporal.PlainYearMonth(2019, 6); + // => 2019-06 +} + +{ + let ym: Temporal.PlainYearMonth; + + ym = Temporal.PlainYearMonth.from("2019-06"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]"); + // => 2019-06 + ym === Temporal.PlainYearMonth.from(ym); // => false + + ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }); // => 2019-06 + ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")); + // => 2019-06 + // (same as above; Temporal.PlainDate has year and month properties) + + // Different overflow modes + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }); + // => 2001-12 + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainYearMonth.from("2006-08"); + const two = Temporal.PlainYearMonth.from("2015-07"); + const three = Temporal.PlainYearMonth.from("1930-02"); + const sorted = [one, two, three].sort(Temporal.PlainYearMonth.compare); + sorted.join(" "); // => '1930-02 2006-08 2015-07' +} + +{ + let ym: Temporal.PlainYearMonth; + + ym = Temporal.PlainYearMonth.from("2019-06"); + ym.year; // => 2019 + ym.month; // => 6 + ym.monthCode; // => 'M06' + + ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]"); + ym.year; // => 5779 + ym.month; // => 6 + ym.monthCode; // => 'M05L' +} + +{ + const ym = Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]"); + ym.era; + // => 'bce' + ym.eraYear; + // => 16 + ym.year; + // => -15 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const ym = Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }); + monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym); + } + + const strings = monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }); + const percent = ym.daysInMonth / ym.daysInYear; + `${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!`; + // => 'June 2019 was 8% of the year!' +} + +{ + const ym = Temporal.PlainYearMonth.from("1900-01"); + ym.monthsInYear; // => 12 +} + +{ + // Was June 2019 in a leap year? + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.inLeapYear; // => false + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + ym.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + // Get December of that year + ym.with({ month: 12 }); // => 2019-12 +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.add({ years: 20, months: 4 }); // => 2039-10 +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.subtract({ years: 20, months: 4 }); // => 1999-02 +} + +{ + const ym = Temporal.PlainYearMonth.from("2006-08"); + const other = Temporal.PlainYearMonth.from("2019-06"); + ym.until(other); // => P12Y10M + ym.until(other, { largestUnit: "month" }); // => P154M + other.until(ym, { largestUnit: "month" }); // => -P154M + + // If you really need to calculate the difference between two YearMonths + // in days, you can eliminate the ambiguity by explicitly choosing the + // day of the month (and if applicable, the time of that day) from which + // you want to reckon the difference. For example, using the first of + // the month to calculate a number of days: + ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }); // => P4687D +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.since(other); // => P12Y10M +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.equals(other); // => false + ym.equals(ym); // => true +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toString(); // => '2019-06' +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }); + ym.toLocaleString(); // example output: '6/2019' + // Same as above, but explicitly specifying the calendar: + ym.toLocaleString(undefined, { calendar }); + + ym.toLocaleString("de-DE", { calendar }); // example output: '6.2019' + ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }); // => 'Juni 2019' + ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '6/2019' +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toPlainDate({ day: 24 }); // => 2019-06-24 +} + +{ + let md: Temporal.PlainMonthDay; + + // Pi day + md = new Temporal.PlainMonthDay(3, 14); // => 03-14 + // Leap day + md = new Temporal.PlainMonthDay(2, 29); // => 02-29 +} + +{ + let md: Temporal.PlainMonthDay; + + md = Temporal.PlainMonthDay.from("08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("0824"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 08-24 + md === Temporal.PlainMonthDay.from(md); // => false + + md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }); // => 08-24 + md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")); + // => 08-24 + // (same as above; Temporal.PlainDate has month and day properties) + + // Different overflow modes + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }); + // => 12-01 + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }); + // => 01-31 + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }); + // => throws (this year is not a leap year in the ISO 8601 calendar) + + // non-ISO calendars + md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + /* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }); + // => throws (either year or monthCode is required) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // undefined + // (month property is not present in this type; use monthCode instead) +} + +{ + let md: Temporal.PlainMonthDay; + + md = Temporal.PlainMonthDay.from("08-24"); + md.monthCode; // => 'M08' + md.day; // => 24 + md.month; // => undefined + // (no `month` property; use `monthCode` instead) + + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // => undefined + // (no `month` property; use `monthCode` instead) +} + +{ + const md = Temporal.PlainMonthDay.from("11-15"); + // What's the last day of that month? + md.with({ day: 31 }); // => 11-30 + Temporal.PlainMonthDay.from("02-01").with({ day: 31 }); // => 02-29 +} + +{ + const md1 = Temporal.PlainMonthDay.from("02-28"); + const md2 = Temporal.PlainMonthDay.from("02-29"); + md1.equals(md2); // => false + md1.equals("02-29"); // => false + md1.equals({ monthCode: "M02", day: 29 }); // => false + md2.equals(md2); // => true + md2.equals("02-29"); // => true + md2.equals({ monthCode: "M02", day: 29 }); // => true +} + +{ + const md = Temporal.PlainMonthDay.from("08-24"); + md.toString(); // => '08-24' +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }); + md.toLocaleString(); // example output: '8/24' + // Same as above, but explicitly specifying the calendar: + md.toLocaleString(undefined, { calendar }); // example output: '8/24' + + md.toLocaleString("de-DE", { calendar }); // => '24.8.' + md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }); // => '24. August' + md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '8/24' +} + +{ + const md = Temporal.PlainMonthDay.from({ + calendar: "japanese", + monthCode: "M01", + day: 1, + }); + + const date = md.toPlainDate({ era: "reiwa", eraYear: 2 }); // => 2020-01-01[u-ca=japanese] +} + +{ + new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); // => P1Y2M3W4DT5H6M7.987654321S + new Temporal.Duration(0, 0, 0, 40); // => P40D + new Temporal.Duration(undefined, undefined, undefined, 40); // => P40D + new Temporal.Duration(); // => PT0S +} + +{ + let d: Temporal.Duration; + + d = Temporal.Duration.from({ years: 1, days: 1 }); // => P1Y1D + d = Temporal.Duration.from({ days: -2, hours: -12 }); // => -P2DT12H + + Temporal.Duration.from(d) === d; // => false + + d = Temporal.Duration.from("P1Y1D"); // => P1Y1D + d = Temporal.Duration.from("-P2DT12H"); // => -P2DT12H + d = Temporal.Duration.from("P0D"); // => PT0S +} + +{ + const one = Temporal.Duration.from({ hours: 79, minutes: 10 }); + const two = Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }); + const three = Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }); + const sorted1 = [one, two, three].sort(Temporal.Duration.compare); + sorted1.join(" "); + // => 'P3DT6H50M PT79H10M P3DT7H630S' + + // Sorting relative to a date, taking DST changes into account: + const relativeTo = Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]"); + const sorted2 = [one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })); + sorted2.join(" "); + // => 'PT79H10M P3DT6H50M P3DT7H630S' +} + +{ + const d = Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S"); + d.years; // => 1 + d.months; // => 2 + d.weeks; // => 3 + d.days; // => 4 + d.hours; // => 5 + d.minutes; // => 6 + d.seconds; // => 7 + d.milliseconds; // => 987 + d.microseconds; // => 654 + d.nanoseconds; // => 321 +} + +{ + let d: Temporal.Duration; + + d = Temporal.Duration.from("PT0S"); + d.blank; // => true + + d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }); + d.blank; // => true +} + +{ + let duration: Temporal.Duration; + + duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }); + // Perform a balance operation using additional ISO 8601 calendar rules: + let { years, months } = duration; + years += Math.floor(months / 12); + months %= 12; + duration = duration.with({ years, months }); + // => P4Y2M50DT50H100M +} + +{ + const hour = Temporal.Duration.from("PT1H"); + hour.add({ minutes: 30 }); // => PT1H30M + + // Examples of balancing: + const one = Temporal.Duration.from({ hours: 1, minutes: 30 }); + const two = Temporal.Duration.from({ hours: 2, minutes: 45 }); + const result = one.add(two); // => PT4H15M + + // Example of adding calendar units + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 16 }); + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2000-12-01"); + startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P3M4D + + const startDate2 = Temporal.PlainDate.from("2001-01-01"); + startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P3M1D +} + +{ + const hourAndAHalf = Temporal.Duration.from("PT1H30M"); + hourAndAHalf.subtract({ hours: 1 }); // => PT30M + + const one = Temporal.Duration.from({ minutes: 180 }); + const two = Temporal.Duration.from({ seconds: 30 }); + one.subtract(two); // => PT179M30S + one.subtract(two).round({ largestUnit: "hour" }); // => PT2H59M30S + + // Example of subtracting calendar units; cannot be subtracted using + // subtract() because units need to be converted + const threeMonths = Temporal.Duration.from({ months: 3 }); + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 15 }); + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2001-01-01"); + startDate1.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P1M13D + + const startDate2 = Temporal.PlainDate.from("2001-02-01"); + startDate2.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P1M16D +} + +{ + const d = Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S"); + d.sign; // 1 + d.negated(); // -P1Y2M3DT4H5M6.987654321S + d.negated().sign; // -1 +} + +{ + const d = Temporal.Duration.from("-PT8H30M"); + d.abs(); // PT8H30M +} + +{ + let d: Temporal.Duration; + + // Balance a duration as far as possible without knowing a starting point + d = Temporal.Duration.from({ minutes: 130 }); + d.round({ largestUnit: "day" }); // => PT2H10M + + // Round to the nearest unit + d = Temporal.Duration.from({ minutes: 10, seconds: 52 }); + d.round({ smallestUnit: "minute" }); // => PT11M + d.round({ smallestUnit: "minute", roundingMode: "trunc" }); // => PT10M + + // How many seconds in a multi-unit duration? + d = Temporal.Duration.from("PT2H34M18S"); + d.round({ largestUnit: "second" }).seconds; // => 9258 + + // Normalize, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.round({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + largestUnit: "year", + }); // => P114DT21H + // (one hour longer because DST skipped an hour) + d.round({ + relativeTo: "2020-01-01", + largestUnit: "year", + }); // => P114DT20H + // (one hour shorter if ignoring DST) + + // Normalize days into months or years + d = Temporal.Duration.from({ days: 190 }); + const refDate = Temporal.PlainDate.from("2020-01-01"); + d.round({ relativeTo: refDate, largestUnit: "year" }); // => P6M8D + + // Same, but in a different calendar system + d.round({ + relativeTo: refDate.withCalendar("hebrew"), + largestUnit: "year", + }); // => P6M13D + + // Round a duration up to the next 5-minute billing period + d = Temporal.Duration.from({ minutes: 6 }); + d.round({ + smallestUnit: "minute", + roundingIncrement: 5, + roundingMode: "ceil", + }); // => PT10M + + // How many full 3-month quarters of this year, are in this duration? + d = Temporal.Duration.from({ months: 10, days: 15 }); + d = d.round({ + smallestUnit: "month", + roundingIncrement: 3, + roundingMode: "trunc", + relativeTo: Temporal.Now.plainDateISO(), + }); + const quarters = d.months / 3; + quarters; // => 3 +} + +{ + let d: Temporal.Duration; + + // How many seconds in 130 hours and 20 minutes? + d = Temporal.Duration.from({ hours: 130, minutes: 20 }); + d.total({ unit: "second" }); // => 469200 + + // How many 24-hour days is 123456789 seconds? + d = Temporal.Duration.from("PT123456789S"); + d.total({ unit: "day" }); // 1428.8980208333332 + + // Find totals in months, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.total({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + unit: "month", + }); // => 3.7958333333333334 + d.total({ + unit: "month", + relativeTo: "2020-01-01", + }); // => 3.7944444444444443 +} + +{ + let d: Temporal.Duration; + + d = Temporal.Duration.from({ years: 1, days: 1 }); + d.toString(); // => P1Y1D + d = Temporal.Duration.from({ years: -1, days: -1 }); + d.toString(); // => -P1Y1D + d = Temporal.Duration.from({ milliseconds: 1000 }); + d.toString(); // => PT1S + + // The output format always balances units under 1 s, even if the + // underlying Temporal.Duration object doesn't. + const nobal = Temporal.Duration.from({ milliseconds: 3500 }); + console.log(`${nobal}`, nobal.seconds, nobal.milliseconds); // => 'PT3.5S 0 3500' + const bal = nobal.round({ largestUnit: "year" }); // balance through round + console.log(`${bal}`, bal.seconds, bal.milliseconds); // => 'PT3.5S 3 500' + + d = Temporal.Duration.from("PT59.999999999S"); + d.toString({ smallestUnit: "second" }); // => PT59S + d.toString({ fractionalSecondDigits: 0 }); // => PT59S + d.toString({ fractionalSecondDigits: 4 }); // => PT59.9999S + d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => PT60.00000000S +} + +{ + const d = Temporal.Duration.from("P1DT6H30M"); + d.toLocaleString(); // example output: '1 day 6 hours 30 minutes' + d.toLocaleString("de-DE"); // example output: '1 Tag 6 Stunden 30 Minuten' + d.toLocaleString("en-US", { days: "short", hours: "numeric" }); // example output: '1 day 6 hours' +} + +{ + Temporal.Now.instant(); // get the current system exact time + Temporal.Now.timeZoneId(); // get the current system time zone + Temporal.Now.zonedDateTimeISO(); // get the current date and wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateISO(); // get the current date in the system time zone and ISO-8601 calendar + Temporal.Now.plainTimeISO(); // get the current wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateTimeISO(); // same as above, but return the DateTime in the ISO-8601 calendar +} + + +//// [temporal.js] +"use strict"; +/** + * Test cases derived from documentation at tc39/proposal-temporal, + * under the following license: + * + * Copyright 2017, 2018, 2019, 2020 ECMA International + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +{ + const instant = Temporal.Instant.from("2020-01-01T00:00+05:30"); // => 2019-12-31T18:30:00Z + instant.epochNanoseconds; // => 1577817000000000000n + // `Temporal.Instant` lacks properties that depend on time zone or calendar + instant.year; // => undefined + const zdtTokyo = instant.toZonedDateTimeISO("Asia/Tokyo"); // => 2020-01-01T03:30:00+09:00[Asia/Tokyo] + zdtTokyo.year; // => 2020 + zdtTokyo.toPlainDate(); // => 2020-01-01 +} +{ + // Convert from `Temporal.Instant` to `Date` (which uses millisecond precision) + const instant = Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30"); + // => 2019-12-31T18:30:00.123456789Z + const date = new Date(instant.epochMilliseconds); + date.toISOString(); // => 2019-12-31T18:30:00.123Z + // Convert from `Date` to `Temporal.Instant` + const sameInstant = date.toTemporalInstant(); // => 2019-12-31T18:30:00.123Z +} +{ + const date = new Date(2019, 11, 31, 18, 30); // => Tue Dec 31 2019 18:30:00 GMT-0800 (Pacific Standard Time) + const instant = date.toTemporalInstant(); // => 2020-01-01T02:30:00Z + const zonedDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()); + // => 2019-12-31T18:30:00-08:00[America/Los_Angeles] + zonedDateTime.day; // => 31 + const dateOnly = zonedDateTime.toPlainDate(); // => 2019-12-31 +} +{ + const instant = new Temporal.Instant(1553906700000000000n); + // When was the Unix epoch? + const epoch = new Temporal.Instant(0n); // => 1970-01-01T00:00:00Z + // Dates before the Unix epoch are negative + const turnOfTheCentury = new Temporal.Instant(-2208988800000000000n); // => 1900-01-01T00:00:00Z +} +{ + let instant; + instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]"); + instant = Temporal.Instant.from("2019-03-30T01:45+01:00"); + instant = Temporal.Instant.from("2019-03-30T00:45Z"); + instant === Temporal.Instant.from(instant); // => false +} +{ + const legacyDate = new Date("1995-12-17T03:24Z"); + let instant; + instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()); // => 1995-12-17T03:24:00Z + instant = legacyDate.toTemporalInstant(); // recommended +} +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + const three = Temporal.Instant.fromEpochMilliseconds(1.2e12); + const sorted = [three, one, two].sort(Temporal.Instant.compare); + sorted.join(" "); + // => '2001-09-09T01:46:40Z 2004-11-09T11:33:20Z 2008-01-10T21:20:00Z' +} +{ + const instant = Temporal.Instant.from("2019-03-30T00:45Z"); + new Date(instant.epochMilliseconds); // => 2019-03-30T00:45:00.000Z + // If you need epoch seconds data: + const epochSecs = Math.floor(instant.epochMilliseconds / 1000); // => 1553906700 + const ns = instant.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +} +{ + // Converting a specific exact time to a calendar date / wall-clock time + let timestamp; + timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100000); + timestamp.toZonedDateTimeISO("Europe/Berlin"); // => 2019-03-31T01:45:00+01:00[Europe/Berlin] + timestamp.toZonedDateTimeISO("UTC"); // => 2019-03-31T00:45:00+00:00[UTC] + timestamp.toZonedDateTimeISO("-08:00"); // => 2019-03-30T16:45:00-08:00[-08:00] + // What time was the Unix epoch (timestamp 0) in Bell Labs (Murray Hill, New Jersey, USA) in the Gregorian calendar? + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory"); + // => 1969-12-31T19:00:00-05:00[America/New_York][u-ca=gregory] + // What time was the Unix epoch in Tokyo in the Japanese calendar? + const zdt = epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese"); + // => 1970-01-01T09:00:00+09:00[Asia/Tokyo][u-ca=japanese] + console.log(zdt.eraYear, zdt.era); + // => '45 showa' +} +{ + // Temporal.Instant representing five hours from now + Temporal.Now.instant().add({ hours: 5 }); + const fiveHours = Temporal.Duration.from({ hours: 5 }); + Temporal.Now.instant().add(fiveHours); +} +{ + // Temporal.Instant representing this time an hour ago + Temporal.Now.instant().subtract({ hours: 1 }); + const oneHour = Temporal.Duration.from({ hours: 1 }); + Temporal.Now.instant().subtract(oneHour); +} +{ + const startOfMoonMission = Temporal.Instant.from("1969-07-16T13:32:00Z"); + const endOfMoonMission = Temporal.Instant.from("1969-07-24T16:50:35Z"); + const missionLength = startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }); + // => PT195H18M35S + missionLength.toLocaleString(); + // example output: '195 hours 18 minutes 35 seconds' + // Rounding, for example if you don't care about the minutes and seconds + const approxMissionLength = startOfMoonMission.until(endOfMoonMission, { + largestUnit: "hour", + smallestUnit: "hour", + }); + // => PT195H + // A billion (10^9) seconds since the epoch in different units + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + const billion = Temporal.Instant.fromEpochMilliseconds(1e9); + epoch.until(billion); + // => PT1000000000S + epoch.until(billion, { largestUnit: "hour" }); + // => PT277777H46M40S + const ns = epoch.until(billion, { largestUnit: "nanosecond" }); + // => PT1000000000S + ns.add({ nanoseconds: 1 }); + // => PT1000000000S + // (lost precision) + // Calculate the difference in years, eliminating the ambiguity by + // explicitly using the corresponding calendar date in UTC: + epoch.toZonedDateTimeISO("UTC").until(billion.toZonedDateTimeISO("UTC"), { largestUnit: "year" }); + // => P31Y8M8DT1H46M40S +} +{ + const instant = Temporal.Instant.from("2019-03-30T02:45:59.999999999Z"); + // Round to a particular unit + instant.round({ smallestUnit: "second" }); // => 2019-03-30T02:46:00Z + // Round to an increment of a unit, e.g. an hour: + instant.round({ roundingIncrement: 60, smallestUnit: "minute" }); + // => 2019-03-30T03:00:00Z + // Round to the same increment but round down instead: + instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }); + // => 2019-03-30T02:00:00Z +} +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + one.equals(two); // => false + one.equals(one); // => true +} +{ + const instant = Temporal.Instant.fromEpochMilliseconds(1574074321816); + instant.toString(); // => '2019-11-18T10:52:01.816Z' + instant.toString({ timeZone: "UTC" }); + // => '2019-11-18T10:52:01.816+00:00' + instant.toString({ timeZone: "Asia/Seoul" }); + // => '2019-11-18T19:52:01.816+09:00' + instant.toString({ smallestUnit: "minute" }); + // => '2019-11-18T10:52Z' + instant.toString({ fractionalSecondDigits: 0 }); + // => '2019-11-18T10:52:01Z' + instant.toString({ fractionalSecondDigits: 4 }); + // => '2019-11-18T10:52:01.8160Z' + instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }); + // => '2019-11-18T10:52:02Z' +} +{ + const instant = Temporal.Instant.from("2019-11-18T11:00:00.000Z"); + instant.toLocaleString(); // example output: '2019-11-18, 3:00:00 a.m.' + instant.toLocaleString("de-DE"); // example output: '18.11.2019, 03:00:00' + instant.toLocaleString("de-DE", { + timeZone: "Europe/Berlin", + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + timeZoneName: "long", + }); // => '18.11.2019, 12:00 Mitteleuropäische Normalzeit' + instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { + timeZone: "Asia/Kolkata", + }); // => '11/18/2019, 4:30:00 PM' +} +{ + // UNIX epoch in California + new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + // same, but shorter +} +{ + let zdt; + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); + zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); + zdt = Temporal.ZonedDateTime.from({ + timeZone: "America/Los_Angeles", + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] + // Different overflow modes + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00+01:00[Europe/Paris] + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws RangeError +} +{ + const arr = [ + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), + ]; + const sorted = arr.sort(Temporal.ZonedDateTime.compare); + JSON.stringify(sorted, undefined, 2); + // => + // '[ + // "2020-02-01T12:30+01:00[Europe/Brussels]", + // "2020-02-01T12:30+00:00[Europe/London]", + // "2020-02-01T12:30-05:00[America/Toronto]", + // "2020-02-01T12:30-05:00[America/New_York]" + // ]' +} +{ + const dt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 +} +{ + const zdt = Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]"); + const epochMs = zdt.epochMilliseconds; + // => 1580527800000 + zdt.toInstant().epochMilliseconds; + // => 1580527800000 + const legacyDate = new Date(epochMs); + // => 2020-02-01T03:30:00.000Z + // (if the system time zone is America/Los_Angeles) + const epochNanos = zdt.epochNanoseconds; + // => 1580527800000000000n + // If you need epoch seconds data: + const epochSecs = Math.floor(zdt.epochMilliseconds / 1000); // => 1553906700 + // => 1580527800 + // If you need epoch microseconds data: + // (Note the extra check for correct floor rounding with bigints) + const ns = zdt.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); + // => 1580527800000000n +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + `Time zone is: ${zdt.timeZoneId}`; + // => 'Time zone is: America/Los_Angeles' + zdt.withTimeZone("Asia/Kolkata").timeZoneId; + // => Asia/Kolkata + zdt.withTimeZone("Asia/Calcutta").timeZoneId; + // => Asia/Calcutta (does not follow links in the IANA Time Zone Database) + zdt.withTimeZone("europe/paris").timeZoneId; + // => Europe/Paris (normalized to match IANA Time Zone Database capitalization) + zdt.withTimeZone("+05:00").timeZoneId; + // => +05:00 + zdt.withTimeZone("+05").timeZoneId; + // => +05:00 (normalized to ±HH:MM) + zdt.withTimeZone("+0500").timeZoneId; + // => +05:00 (normalized to ±HH:MM) +} +{ + const date = Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1]; // => 'THU' +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + // ISO ordinal date + console.log(zdt.year, zdt.dayOfYear); // => '1995 341' +} +{ + const zdt = Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]"); + // ISO week date + console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek); // => '2021 52 6' +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + zdt.daysInWeek; // => 7 +} +{ + // Attempt to write some mnemonic poetry + const monthsByDays = {}; + for (let month = 1; month <= 12; month++) { + const zdt = Temporal.Now.zonedDateTimeISO().with({ month }); + monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt); + } + const strings = monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + console.log(poem); +} +{ + const zdt = Temporal.Now.zonedDateTimeISO(); + const percent = zdt.dayOfYear / zdt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} +{ + const zdt = Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]"); + zdt.monthsInYear; // => 12 +} +{ + // Is this year a leap year? + const zdt = Temporal.Now.zonedDateTimeISO(); + zdt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + zdt.with({ year: 2100 }).inLeapYear; // => false +} +{ + const zdt = Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]"); + zdt.hoursInDay; // 25 +} +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offsetNanoseconds; + // => -25200000000000 + // (-7 * 3600 * 1e9) +} +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offset; + // => '-07:00' + zdt.withTimeZone("Asia/Kolkata").offset; + // => '+05:30' + const minus8Hours = "-08:00"; + const daylightTime0130 = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + // => 2020-11-01T01:30:00-07:00[America/Los_Angeles] + // This is Pacific Daylight Time 1:30AM + const repeated0130 = daylightTime0130.with({ offset: minus8Hours }); + // => 2020-11-01T01:30:00-08:00[America/Los_Angeles] + // This is Pacific Standard Time 1:30AM +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]"); + zdt.with({ year: 2015, minute: 31 }); // => 2015-12-07T03:31:00-06:00[America/Chicago] +} +{ + const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + zdt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00-08:00[America/Los_Angeles] + const time = Temporal.PlainTime.from("11:22"); + zdt.withPlainTime(time); // => 2015-12-07T11:22:00-08:00[America/Los_Angeles] + zdt.withPlainTime("12:34"); // => 2015-12-07T12:34:00-08:00[America/Los_Angeles] + // easier for chaining + zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00-08:00[America/Los_Angeles] +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]"); + zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]' + zdt.withTimeZone("Africa/Accra").toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]' +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]"); + `${zdt.era} ${zdt.eraYear}`; // => 'heisei 7' + zdt.withCalendar("gregory").eraYear; // => 1995 +} +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const laterDay = zdt.add({ days: 1 }); + // => 2020-03-09T00:00:00-07:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + laterDay.since(zdt, { largestUnit: "hour" }).hours; + // => 23 + // because one clock hour lost to DST + const laterHours = zdt.add({ hours: 24 }); + // => 2020-03-09T01:00:00-07:00[America/Los_Angeles] + // Adding time units doesn't adjust for DST. Result is 1:00AM: 24 real-world + // hours later because a clock hour was skipped by DST. + laterHours.since(zdt, { largestUnit: "hour" }).hours; // => 24 +} +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const earlierDay = zdt.subtract({ days: 1 }); + // => 2020-03-08T00:00:00-08:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + earlierDay.since(zdt, { largestUnit: "hour" }).hours; + // => -23 + // because one clock hour lost to DST + const earlierHours = zdt.subtract({ hours: 24 }); + // => 2020-03-07T23:00:00-08:00[America/Los_Angeles] + // Subtracting time units doesn't adjust for DST. Result is 11:00PM: 24 real-world + // hours earlier because a clock hour was skipped by DST. + earlierHours.since(zdt, { largestUnit: "hour" }).hours; // => -24 +} +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt1.until(zdt2); + // => PT202956H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + zdt2.until(zdt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + // Rounding, for example if you don't care about sub-seconds + zdt1.until(zdt2, { smallestUnit: "second" }); + // => PT202956H5M29S + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })); + jan1.until(feb1, { largestUnit: "day" }); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1, { largestUnit: "day" }); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1, { largestUnit: "day" }); // => P60D +} +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt2.since(zdt1); // => PT202956H5M29.9999965S +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + // Round to a particular unit + zdt.round({ smallestUnit: "hour" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + // Round to an increment of a unit, e.g. half an hour: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00-08:00[America/Los_Angeles] + // Round to the same increment but round down instead: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] +} +{ + const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); + zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] +} +{ + let duration; + // How long until the next offset change from now, in the current location? + const tz = Temporal.Now.timeZoneId(); + const now = Temporal.Now.zonedDateTimeISO(tz); + const nextTransition = now.getTimeZoneTransition("next"); + duration = nextTransition.since(now); + duration.toLocaleString(); // output will vary + // How long until the previous offset change from now, in the current location? + const previousTransition = now.getTimeZoneTransition("previous"); + duration = now.since(previousTransition); + duration.toLocaleString(); // output will vary +} +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]"); + const zdt2 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]"); + zdt1.equals(zdt2); // => false (same offset but different time zones) + zdt1.equals(zdt1); // => true + // To compare time zone IDs, use withTimeZone() with each ID on the same + // ZonedDateTime instance, and use equals() to compare + const kolkata = zdt1.withTimeZone("Asia/Kolkata"); + kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")); // => true + // Offset time zones are never equivalent to named time zones + kolkata.equals(zdt1.withTimeZone("+05:30")); // => false + const zeroOffset = zdt1.withTimeZone("+00:00"); + zeroOffset.equals(zdt1.withTimeZone("UTC")); // => false + // For offset time zones, any valid format is accepted + zeroOffset.equals(zdt1.withTimeZone("+00:00")); // => true + zeroOffset.equals(zdt1.withTimeZone("+0000")); // => true + zeroOffset.equals(zdt1.withTimeZone("+00")); // => true +} +{ + let zdt; + zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos]' + zdt = zdt.withCalendar("japanese"); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos][u-ca=japanese]' +} +{ + const zdt = Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]"); + zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM + zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' + const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" }; + zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' + /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); + // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin + zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' + zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' +} +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]"); + zdt.toInstant(); // => 1995-12-07T01:24:30Z + zdt.toPlainDateTime(); // => 1995-12-07T03:24:30 + zdt.toPlainDate(); // => 1995-12-07 + zdt.toPlainTime(); // => 03:24:30 + zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 + zdt.toPlainDate().toPlainMonthDay(); // => 12-07 +} +{ + // Pi day in 2020 + const date = new Temporal.PlainDate(2020, 3, 14); // => 2020-03-14 +} +{ + let date; + date = Temporal.PlainDate.from("2006-08-24"); // => 2006-08-24 + date = Temporal.PlainDate.from("20060824"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 2006-08-24 + date === Temporal.PlainDate.from(date); // => false + date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24 + date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")); + // => 2006-08-24 + // same as above; Temporal.PlainDateTime has year, month, and day properties + date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }); + // => 2006-08-24[u-ca=islamic] + // Different overflow modes + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01 + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31 + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws +} +{ + const one = Temporal.PlainDate.from("2006-08-24"); + const two = Temporal.PlainDate.from("2015-07-14"); + const three = Temporal.PlainDate.from("1930-02-18"); + const sorted = [one, two, three].sort(Temporal.PlainDate.compare); + sorted.join(" "); // => '1930-02-18 2006-08-24 2015-07-14' +} +{ + let date; + date = Temporal.PlainDate.from("2006-08-24"); + date.year; // => 2006 + date.month; // => 8 + date.monthCode; // => 'M08' + date.day; // => 24 + date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]"); + date.year; // => 5779 + date.month; // => 6 + date.monthCode; // => 'M05L' + date.day; // => 18 +} +{ + const date = Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1]; // => 'THU' +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + // ISO ordinal date + console.log(date.year, date.dayOfYear); // => '2006 236' +} +{ + const date = Temporal.PlainDate.from("2022-01-01"); + // ISO week date + console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek); // => '2021 52 6' +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.daysInWeek; // => 7 +} +{ + // Attempt to write some mnemonic poetry + const monthsByDays = {}; + for (let month = 1; month <= 12; month++) { + const date = Temporal.Now.plainDateISO().with({ month }); + monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date); + } + const strings = monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + console.log(poem); +} +{ + const date = Temporal.Now.plainDateISO(); + const percent = date.dayOfYear / date.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} +{ + const date = Temporal.PlainDate.from("1900-01-01"); + date.monthsInYear; // => 12 +} +{ + // Is this year a leap year? + const date = Temporal.Now.plainDateISO(); + date.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + date.with({ year: 2100 }).inLeapYear; // => false +} +{ + const date = Temporal.PlainDate.from("2006-01-24"); + // What's the first day of this month? + date.with({ day: 1 }); // => 2006-01-01 + // What's the last day of the next month? + const nextMonthDate = date.add({ months: 1 }); + nextMonthDate.with({ day: nextMonthDate.daysInMonth }); // => 2006-02-28 +} +{ + const date = Temporal.PlainDate.from("2006-08-24[u-ca=japanese]"); + date.withCalendar("iso8601"); // => 2006-08-24 +} +{ + let date; + date = Temporal.PlainDate.from("2006-08-24"); + date.add({ years: 20, months: 4 }); // => 2026-12-24 + date = Temporal.PlainDate.from("2019-01-31"); + date.add({ months: 1 }); // => 2019-02-28 + date.add({ months: 1 }, { overflow: "reject" }); // => throws +} +{ + let date; + date = Temporal.PlainDate.from("2006-08-24"); + date.subtract({ years: 20, months: 4 }); // => 1986-04-24 + date = Temporal.PlainDate.from("2019-03-31"); + date.subtract({ months: 1 }); // => 2019-02-28 + date.subtract({ months: 1 }, { overflow: "reject" }); // => throws +} +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + earlier.until(later); // => P4543D + earlier.until(later, { largestUnit: "year" }); // => P12Y5M7D + later.until(earlier, { largestUnit: "year" }); // => -P12Y5M7D + // If you really need to calculate the difference between two Dates in + // hours, you can eliminate the ambiguity by explicitly choosing the + // point in time from which you want to reckon the difference. For + // example, using noon: + const noon = Temporal.PlainTime.from("12:00"); + earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }); + // => PT109032H + const newyear = Temporal.PlainDate.from("2020-01-01"); + newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S + newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S (mid-month dates rounded down to match `Temporal.PlainDateTime` behavior) + newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT1M +} +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + later.since(earlier); // => P4543D +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + const other = Temporal.PlainDate.from("2019-01-31"); + date.equals(other); // => false + date.equals(date); // => true +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toString(); // => '2006-08-24' +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toLocaleString(); // example output: 8/24/2006 + date.toLocaleString("de-DE"); // example output: '24.8.2006' + date.toLocaleString("de-DE", { weekday: "long" }); // => 'Donnerstag' + date.toLocaleString("en-US-u-nu-fullwide"); // => '8/24/2006' +} +{ + const plainDate = Temporal.PlainDate.from("2006-08-24"); + const plainTime = Temporal.PlainTime.from("15:23:30.003"); + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }); + // => 2006-08-24T15:23:30.003-07:00[America/Los_Angeles] + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }); + // => 2006-08-24T00:00:00-07:00[America/Los_Angeles] +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + const time = Temporal.PlainTime.from("15:23:30.003"); + date.toPlainDateTime(time); // => 2006-08-24T15:23:30.003 + date.toPlainDateTime(); // => 2006-08-24T00:00:00 +} +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toPlainYearMonth(); // => 2006-08 + date.toPlainMonthDay(); // => 08-24 +} +{ + // Leet hour + const time = new Temporal.PlainTime(13, 37); // => 13:37:00 +} +{ + let time; + time = Temporal.PlainTime.from("03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("032430"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 03:24:30 + // (same as above; time zone is ignored) + time === Temporal.PlainTime.from(time); // => false + time = Temporal.PlainTime.from({ + hour: 19, + minute: 39, + second: 9, + millisecond: 68, + microsecond: 346, + nanosecond: 205, + }); // => 19:39:09.068346205 + time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }); // => 19:39:09 + time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")); + // => 19:39:09 + // (same as above; Temporal.PlainDateTime has hour, minute, etc. properties) + // Different overflow modes + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }); + // => 15:59:00 + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }); + // => 15:00:00 + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }); + // => throws + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }); + // => throws +} +{ + const one = Temporal.PlainTime.from("03:24"); + const two = Temporal.PlainTime.from("01:24"); + const three = Temporal.PlainTime.from("01:24:05"); + const sorted = [one, two, three].sort(Temporal.PlainTime.compare); + sorted.join(" "); // => '01:24:00 01:24:05 03:24:00' +} +{ + // Backward transitions will repeat clock times + const zdtDst = Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]"); + const zdtStandard = Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]"); + // The "first" 1:45 (in Daylight Time) is earlier than the "second" 1:30 (in Standard Time) + Temporal.ZonedDateTime.compare(zdtDst, zdtStandard); // => -1 + // 1:45 is later than 1:30 when looking at a wall clock + Temporal.PlainTime.compare(zdtDst, zdtStandard); // => 1 + // Forward transitions will skip clock times. Skipped times will be disambiguated. + const zdtBase = Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]"); + const timeSkipped = Temporal.PlainTime.from("02:30"); + const timeValid = Temporal.PlainTime.from("03:30"); + const zdtSkipped = zdtBase.withPlainTime(timeSkipped); + const zdtValid = zdtBase.withPlainTime(timeValid); + // The skipped time 2:30AM is disambiguated to 3:30AM, so the instants are equal + Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid); // => 0 + // 2:30 is earlier than 3:30 on a wall clock + Temporal.PlainTime.compare(timeSkipped, timeValid); // => -1 +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.hour; // => 19 + time.minute; // => 39 + time.second; // => 9 + time.millisecond; // => 68 + time.microsecond; // => 346 + time.nanosecond; // => 205 +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + // What's the top of the next hour? + time.add({ hours: 1 }).with({ + minute: 0, + second: 0, + millisecond: 0, + microsecond: 0, + nanosecond: 0, + }); // => 20:00:00 +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.add({ minutes: 5, nanoseconds: 800 }); // => 19:44:09.068347005 +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.subtract({ minutes: 5, nanoseconds: 800 }); // => 19:34:09.068345405 +} +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.until(Temporal.PlainTime.from("22:39:09.068346205")); // => PT2H25M48.096948106S + time.until(Temporal.PlainTime.from("19:39:09.068346205")); // => -PT34M11.903051894S + // Rounding, for example if you don't care about sub-seconds + time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }); + // => PT2H25M48S +} +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.since(Temporal.PlainTime.from("19:39:09.068346205")); // => PT34M11.903051894S + time.since(Temporal.PlainTime.from("22:39:09.068346205")); // => -PT2H25M48.096948106S +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + // Round to a particular unit + time.round({ smallestUnit: "hour" }); // => 20:00:00 + // Round to an increment of a unit, e.g. half an hour: + time.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 19:30:00 + // Round to the same increment but round up instead: + time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }); + // => 20:00:00 +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + const other = Temporal.PlainTime.from("20:13:20.971398099"); + time.equals(other); // => false + time.equals(time); // => true +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toString(); // => '19:39:09.068346205' + time.toString({ smallestUnit: "minute" }); // => '19:39' + time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09' + time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683' + time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }); + // => '19:39:09.06835' +} +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toLocaleString(); // example output: '7:39:09 PM' + time.toLocaleString("de-DE"); // example output: '19:39:09' + time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }); // => '19:39:09' + time.toLocaleString("en-US-u-nu-fullwide-hc-h24"); // => '19:39:09' +} +{ + // Leet hour on pi day in 2020 + const datetime = new Temporal.PlainDateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37:00 +} +{ + let dt; + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30"); + dt = Temporal.PlainDateTime.from("19951207T032430"); + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 1995-12-07T03:24:30 + // same as above; time zone is ignored + dt === Temporal.PlainDateTime.from(dt); // => false + dt = Temporal.PlainDateTime.from({ + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035 + dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }); // => 1995-12-07T00:00:00 + dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")); + // => 1995-12-07T00:00:00 + // same as above; Temporal.PlainDate has year, month, and day properties + dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }); + // => 1995-12-07T03:24:30[u-ca=hebrew] + // Different overflow modes + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }); + // => 2001-01-01T23:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }); + // => 2001-01-01T00:59:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }); + // => throws +} +{ + const one = Temporal.PlainDateTime.from("1995-12-07T03:24"); + const two = Temporal.PlainDateTime.from("1995-12-07T01:24"); + const three = Temporal.PlainDateTime.from("2015-12-07T01:24"); + const sorted = [one, two, three].sort(Temporal.PlainDateTime.compare); + sorted.join(" "); + // => '1995-12-07T01:24:00 1995-12-07T03:24:00 2015-12-07T01:24:00' +} +{ + let dt; + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 + dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]"); + dt.year; // => 5779 + dt.month; // => 6 + dt.monthCode; // => 'M05L' + dt.day; // => 18 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 +} +{ + const date = Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1]; // => 'THU' +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + // ISO ordinal date + console.log(dt.year, dt.dayOfYear); // => '1995 341' +} +{ + const dt = Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500"); + // ISO week date + console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek); // => '2021 52 6' +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.daysInWeek; // => 7 +} +{ + // Attempt to write some mnemonic poetry + const monthsByDays = {}; + for (let month = 1; month <= 12; month++) { + const dt = Temporal.Now.plainDateTimeISO().with({ month }); + monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt); + } + const strings = monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + console.log(poem); +} +{ + const dt = Temporal.Now.plainDateTimeISO(); + const percent = dt.dayOfYear / dt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} +{ + const dt = Temporal.PlainDate.from("1900-01-01T12:00"); + dt.monthsInYear; // => 12 +} +{ + // Is this year a leap year? + const dt = Temporal.Now.plainDateTimeISO(); + dt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + dt.with({ year: 2100 }).inLeapYear; // => false +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035 +} +{ + const dt = Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500"); + dt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00 + const time = Temporal.PlainTime.from("11:22"); + dt.withPlainTime(time); // => 2015-12-07T11:22:00 + dt.withPlainTime("12:34"); // => 2015-12-07T12:34:00 + // easier for chaining + dt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00 +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]"); + dt.withCalendar("iso8601"); // => 1995-12-07T03:24:30.0000035 +} +{ + let dt; + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.add({ years: 20, months: 4, nanoseconds: 500 }); // => 2016-04-07T03:24:30.000004 + dt = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt.add({ months: 1 }); // => 2019-02-28T15:30:00 + dt.add({ months: 1 }, { overflow: "reject" }); // => throws +} +{ + let dt; + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.subtract({ years: 20, months: 4, nanoseconds: 500 }); // => 1975-08-07T03:24:30.000003 + dt = Temporal.PlainDateTime.from("2019-03-31T15:30"); + dt.subtract({ months: 1 }); // => 2019-02-28T15:30:00 + dt.subtract({ months: 1 }, { overflow: "reject" }); // => throws +} +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.until(dt2); + // => P8456DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + dt2.until(dt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + // Rounding, for example if you don't care about sub-seconds + dt1.until(dt2, { smallestUnit: "second" }); + // => P8456DT12H5M29S + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })); + jan1.until(feb1); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1); // => P60D +} +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt2.since(dt1); // => P8456DT12H5M29.9999965S +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + // Round to a particular unit + dt.round({ smallestUnit: "hour" }); // => 1995-12-07T03:00:00 + // Round to an increment of a unit, e.g. half an hour: + dt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00 + // Round to the same increment but round down instead: + dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00 +} +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.equals(dt2); // => false + dt1.equals(dt1); // => true +} +{ + const dt = Temporal.PlainDateTime.from({ + year: 1999, + month: 12, + day: 31, + hour: 23, + minute: 59, + second: 59, + millisecond: 999, + microsecond: 999, + nanosecond: 999, + }); + dt.toString(); // => '1999-12-31T23:59:59.999999999' + dt.toString({ smallestUnit: "minute" }); // => '1999-12-31T23:59' + dt.toString({ fractionalSecondDigits: 0 }); // => '1999-12-31T23:59:59' + dt.toString({ fractionalSecondDigits: 4 }); // => '1999-12-31T23:59:59.9999' + dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => '2000-01-01T00:00:00.00000000' +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toLocaleString(); // example output: 1995-12-07, 3:24:30 a.m. + dt.toLocaleString("de-DE"); // example output: 7.12.1995, 03:24:30 + dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }); // => 'Donnerstag' + dt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/7/1995, 3:24:30 AM' +} +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toPlainDate(); // => 1995-12-07 + dt.toPlainTime(); // => 03:24:30.0000035 + dt.toPlainDate().toPlainYearMonth(); // => 1995-12 + dt.toPlainDate().toPlainMonthDay(); // => 12-07 +} +{ + // The June 2019 meeting + const ym = new Temporal.PlainYearMonth(2019, 6); + // => 2019-06 +} +{ + let ym; + ym = Temporal.PlainYearMonth.from("2019-06"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]"); + // => 2019-06 + ym === Temporal.PlainYearMonth.from(ym); // => false + ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }); // => 2019-06 + ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")); + // => 2019-06 + // (same as above; Temporal.PlainDate has year and month properties) + // Different overflow modes + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }); + // => 2001-12 + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }); + // => throws +} +{ + const one = Temporal.PlainYearMonth.from("2006-08"); + const two = Temporal.PlainYearMonth.from("2015-07"); + const three = Temporal.PlainYearMonth.from("1930-02"); + const sorted = [one, two, three].sort(Temporal.PlainYearMonth.compare); + sorted.join(" "); // => '1930-02 2006-08 2015-07' +} +{ + let ym; + ym = Temporal.PlainYearMonth.from("2019-06"); + ym.year; // => 2019 + ym.month; // => 6 + ym.monthCode; // => 'M06' + ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]"); + ym.year; // => 5779 + ym.month; // => 6 + ym.monthCode; // => 'M05L' +} +{ + const ym = Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]"); + ym.era; + // => 'bce' + ym.eraYear; + // => 16 + ym.year; + // => -15 +} +{ + // Attempt to write some mnemonic poetry + const monthsByDays = {}; + for (let month = 1; month <= 12; month++) { + const ym = Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }); + monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym); + } + const strings = monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + console.log(poem); +} +{ + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }); + const percent = ym.daysInMonth / ym.daysInYear; + `${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!`; + // => 'June 2019 was 8% of the year!' +} +{ + const ym = Temporal.PlainYearMonth.from("1900-01"); + ym.monthsInYear; // => 12 +} +{ + // Was June 2019 in a leap year? + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.inLeapYear; // => false + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + ym.with({ year: 2100 }).inLeapYear; // => false +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + // Get December of that year + ym.with({ month: 12 }); // => 2019-12 +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.add({ years: 20, months: 4 }); // => 2039-10 +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.subtract({ years: 20, months: 4 }); // => 1999-02 +} +{ + const ym = Temporal.PlainYearMonth.from("2006-08"); + const other = Temporal.PlainYearMonth.from("2019-06"); + ym.until(other); // => P12Y10M + ym.until(other, { largestUnit: "month" }); // => P154M + other.until(ym, { largestUnit: "month" }); // => -P154M + // If you really need to calculate the difference between two YearMonths + // in days, you can eliminate the ambiguity by explicitly choosing the + // day of the month (and if applicable, the time of that day) from which + // you want to reckon the difference. For example, using the first of + // the month to calculate a number of days: + ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }); // => P4687D +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.since(other); // => P12Y10M +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.equals(other); // => false + ym.equals(ym); // => true +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toString(); // => '2019-06' +} +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }); + ym.toLocaleString(); // example output: '6/2019' + // Same as above, but explicitly specifying the calendar: + ym.toLocaleString(undefined, { calendar }); + ym.toLocaleString("de-DE", { calendar }); // example output: '6.2019' + ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }); // => 'Juni 2019' + ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '6/2019' +} +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toPlainDate({ day: 24 }); // => 2019-06-24 +} +{ + let md; + // Pi day + md = new Temporal.PlainMonthDay(3, 14); // => 03-14 + // Leap day + md = new Temporal.PlainMonthDay(2, 29); // => 02-29 +} +{ + let md; + md = Temporal.PlainMonthDay.from("08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("0824"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 08-24 + md === Temporal.PlainMonthDay.from(md); // => false + md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }); // => 08-24 + md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")); + // => 08-24 + // (same as above; Temporal.PlainDate has month and day properties) + // Different overflow modes + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }); + // => 12-01 + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }); + // => 01-31 + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }); + // => throws (this year is not a leap year in the ISO 8601 calendar) + // non-ISO calendars + md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + /* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }); + // => throws (either year or monthCode is required) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // undefined + // (month property is not present in this type; use monthCode instead) +} +{ + let md; + md = Temporal.PlainMonthDay.from("08-24"); + md.monthCode; // => 'M08' + md.day; // => 24 + md.month; // => undefined + // (no `month` property; use `monthCode` instead) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // => undefined + // (no `month` property; use `monthCode` instead) +} +{ + const md = Temporal.PlainMonthDay.from("11-15"); + // What's the last day of that month? + md.with({ day: 31 }); // => 11-30 + Temporal.PlainMonthDay.from("02-01").with({ day: 31 }); // => 02-29 +} +{ + const md1 = Temporal.PlainMonthDay.from("02-28"); + const md2 = Temporal.PlainMonthDay.from("02-29"); + md1.equals(md2); // => false + md1.equals("02-29"); // => false + md1.equals({ monthCode: "M02", day: 29 }); // => false + md2.equals(md2); // => true + md2.equals("02-29"); // => true + md2.equals({ monthCode: "M02", day: 29 }); // => true +} +{ + const md = Temporal.PlainMonthDay.from("08-24"); + md.toString(); // => '08-24' +} +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }); + md.toLocaleString(); // example output: '8/24' + // Same as above, but explicitly specifying the calendar: + md.toLocaleString(undefined, { calendar }); // example output: '8/24' + md.toLocaleString("de-DE", { calendar }); // => '24.8.' + md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }); // => '24. August' + md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '8/24' +} +{ + const md = Temporal.PlainMonthDay.from({ + calendar: "japanese", + monthCode: "M01", + day: 1, + }); + const date = md.toPlainDate({ era: "reiwa", eraYear: 2 }); // => 2020-01-01[u-ca=japanese] +} +{ + new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); // => P1Y2M3W4DT5H6M7.987654321S + new Temporal.Duration(0, 0, 0, 40); // => P40D + new Temporal.Duration(undefined, undefined, undefined, 40); // => P40D + new Temporal.Duration(); // => PT0S +} +{ + let d; + d = Temporal.Duration.from({ years: 1, days: 1 }); // => P1Y1D + d = Temporal.Duration.from({ days: -2, hours: -12 }); // => -P2DT12H + Temporal.Duration.from(d) === d; // => false + d = Temporal.Duration.from("P1Y1D"); // => P1Y1D + d = Temporal.Duration.from("-P2DT12H"); // => -P2DT12H + d = Temporal.Duration.from("P0D"); // => PT0S +} +{ + const one = Temporal.Duration.from({ hours: 79, minutes: 10 }); + const two = Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }); + const three = Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }); + const sorted1 = [one, two, three].sort(Temporal.Duration.compare); + sorted1.join(" "); + // => 'P3DT6H50M PT79H10M P3DT7H630S' + // Sorting relative to a date, taking DST changes into account: + const relativeTo = Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]"); + const sorted2 = [one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })); + sorted2.join(" "); + // => 'PT79H10M P3DT6H50M P3DT7H630S' +} +{ + const d = Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S"); + d.years; // => 1 + d.months; // => 2 + d.weeks; // => 3 + d.days; // => 4 + d.hours; // => 5 + d.minutes; // => 6 + d.seconds; // => 7 + d.milliseconds; // => 987 + d.microseconds; // => 654 + d.nanoseconds; // => 321 +} +{ + let d; + d = Temporal.Duration.from("PT0S"); + d.blank; // => true + d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }); + d.blank; // => true +} +{ + let duration; + duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }); + // Perform a balance operation using additional ISO 8601 calendar rules: + let { years, months } = duration; + years += Math.floor(months / 12); + months %= 12; + duration = duration.with({ years, months }); + // => P4Y2M50DT50H100M +} +{ + const hour = Temporal.Duration.from("PT1H"); + hour.add({ minutes: 30 }); // => PT1H30M + // Examples of balancing: + const one = Temporal.Duration.from({ hours: 1, minutes: 30 }); + const two = Temporal.Duration.from({ hours: 2, minutes: 45 }); + const result = one.add(two); // => PT4H15M + // Example of adding calendar units + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 16 }); + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2000-12-01"); + startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P3M4D + const startDate2 = Temporal.PlainDate.from("2001-01-01"); + startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P3M1D +} +{ + const hourAndAHalf = Temporal.Duration.from("PT1H30M"); + hourAndAHalf.subtract({ hours: 1 }); // => PT30M + const one = Temporal.Duration.from({ minutes: 180 }); + const two = Temporal.Duration.from({ seconds: 30 }); + one.subtract(two); // => PT179M30S + one.subtract(two).round({ largestUnit: "hour" }); // => PT2H59M30S + // Example of subtracting calendar units; cannot be subtracted using + // subtract() because units need to be converted + const threeMonths = Temporal.Duration.from({ months: 3 }); + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 15 }); + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2001-01-01"); + startDate1.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P1M13D + const startDate2 = Temporal.PlainDate.from("2001-02-01"); + startDate2.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P1M16D +} +{ + const d = Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S"); + d.sign; // 1 + d.negated(); // -P1Y2M3DT4H5M6.987654321S + d.negated().sign; // -1 +} +{ + const d = Temporal.Duration.from("-PT8H30M"); + d.abs(); // PT8H30M +} +{ + let d; + // Balance a duration as far as possible without knowing a starting point + d = Temporal.Duration.from({ minutes: 130 }); + d.round({ largestUnit: "day" }); // => PT2H10M + // Round to the nearest unit + d = Temporal.Duration.from({ minutes: 10, seconds: 52 }); + d.round({ smallestUnit: "minute" }); // => PT11M + d.round({ smallestUnit: "minute", roundingMode: "trunc" }); // => PT10M + // How many seconds in a multi-unit duration? + d = Temporal.Duration.from("PT2H34M18S"); + d.round({ largestUnit: "second" }).seconds; // => 9258 + // Normalize, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.round({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + largestUnit: "year", + }); // => P114DT21H + // (one hour longer because DST skipped an hour) + d.round({ + relativeTo: "2020-01-01", + largestUnit: "year", + }); // => P114DT20H + // (one hour shorter if ignoring DST) + // Normalize days into months or years + d = Temporal.Duration.from({ days: 190 }); + const refDate = Temporal.PlainDate.from("2020-01-01"); + d.round({ relativeTo: refDate, largestUnit: "year" }); // => P6M8D + // Same, but in a different calendar system + d.round({ + relativeTo: refDate.withCalendar("hebrew"), + largestUnit: "year", + }); // => P6M13D + // Round a duration up to the next 5-minute billing period + d = Temporal.Duration.from({ minutes: 6 }); + d.round({ + smallestUnit: "minute", + roundingIncrement: 5, + roundingMode: "ceil", + }); // => PT10M + // How many full 3-month quarters of this year, are in this duration? + d = Temporal.Duration.from({ months: 10, days: 15 }); + d = d.round({ + smallestUnit: "month", + roundingIncrement: 3, + roundingMode: "trunc", + relativeTo: Temporal.Now.plainDateISO(), + }); + const quarters = d.months / 3; + quarters; // => 3 +} +{ + let d; + // How many seconds in 130 hours and 20 minutes? + d = Temporal.Duration.from({ hours: 130, minutes: 20 }); + d.total({ unit: "second" }); // => 469200 + // How many 24-hour days is 123456789 seconds? + d = Temporal.Duration.from("PT123456789S"); + d.total({ unit: "day" }); // 1428.8980208333332 + // Find totals in months, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.total({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + unit: "month", + }); // => 3.7958333333333334 + d.total({ + unit: "month", + relativeTo: "2020-01-01", + }); // => 3.7944444444444443 +} +{ + let d; + d = Temporal.Duration.from({ years: 1, days: 1 }); + d.toString(); // => P1Y1D + d = Temporal.Duration.from({ years: -1, days: -1 }); + d.toString(); // => -P1Y1D + d = Temporal.Duration.from({ milliseconds: 1000 }); + d.toString(); // => PT1S + // The output format always balances units under 1 s, even if the + // underlying Temporal.Duration object doesn't. + const nobal = Temporal.Duration.from({ milliseconds: 3500 }); + console.log(`${nobal}`, nobal.seconds, nobal.milliseconds); // => 'PT3.5S 0 3500' + const bal = nobal.round({ largestUnit: "year" }); // balance through round + console.log(`${bal}`, bal.seconds, bal.milliseconds); // => 'PT3.5S 3 500' + d = Temporal.Duration.from("PT59.999999999S"); + d.toString({ smallestUnit: "second" }); // => PT59S + d.toString({ fractionalSecondDigits: 0 }); // => PT59S + d.toString({ fractionalSecondDigits: 4 }); // => PT59.9999S + d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => PT60.00000000S +} +{ + const d = Temporal.Duration.from("P1DT6H30M"); + d.toLocaleString(); // example output: '1 day 6 hours 30 minutes' + d.toLocaleString("de-DE"); // example output: '1 Tag 6 Stunden 30 Minuten' + d.toLocaleString("en-US", { days: "short", hours: "numeric" }); // example output: '1 day 6 hours' +} +{ + Temporal.Now.instant(); // get the current system exact time + Temporal.Now.timeZoneId(); // get the current system time zone + Temporal.Now.zonedDateTimeISO(); // get the current date and wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateISO(); // get the current date in the system time zone and ISO-8601 calendar + Temporal.Now.plainTimeISO(); // get the current wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateTimeISO(); // same as above, but return the DateTime in the ISO-8601 calendar +} diff --git a/tests/baselines/reference/temporal.symbols b/tests/baselines/reference/temporal.symbols new file mode 100644 index 0000000000000..bcd445fd8c059 --- /dev/null +++ b/tests/baselines/reference/temporal.symbols @@ -0,0 +1,7017 @@ +//// [tests/cases/compiler/temporal.ts] //// + +=== temporal.ts === +/** + * Test cases derived from documentation at tc39/proposal-temporal, + * under the following license: + * + * Copyright 2017, 2018, 2019, 2020 ECMA International + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +{ + const instant = Temporal.Instant.from("2020-01-01T00:00+05:30"); // => 2019-12-31T18:30:00Z +>instant : Symbol(instant, Decl(temporal.ts, 20, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant.epochNanoseconds; // => 1577817000000000000n +>instant.epochNanoseconds : Symbol(Temporal.Instant.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 20, 9)) +>epochNanoseconds : Symbol(Temporal.Instant.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // `Temporal.Instant` lacks properties that depend on time zone or calendar + instant.year; // => undefined +>instant : Symbol(instant, Decl(temporal.ts, 20, 9)) + + const zdtTokyo = instant.toZonedDateTimeISO("Asia/Tokyo"); // => 2020-01-01T03:30:00+09:00[Asia/Tokyo] +>zdtTokyo : Symbol(zdtTokyo, Decl(temporal.ts, 26, 9)) +>instant.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 20, 9)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdtTokyo.year; // => 2020 +>zdtTokyo.year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtTokyo : Symbol(zdtTokyo, Decl(temporal.ts, 26, 9)) +>year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdtTokyo.toPlainDate(); // => 2020-01-01 +>zdtTokyo.toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtTokyo : Symbol(zdtTokyo, Decl(temporal.ts, 26, 9)) +>toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Convert from `Temporal.Instant` to `Date` (which uses millisecond precision) + const instant = Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30"); +>instant : Symbol(instant, Decl(temporal.ts, 33, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2019-12-31T18:30:00.123456789Z + const date = new Date(instant.epochMilliseconds); +>date : Symbol(date, Decl(temporal.ts, 35, 9)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.date.d.ts, --, --)) +>instant.epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 33, 9)) +>epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toISOString(); // => 2019-12-31T18:30:00.123Z +>date.toISOString : Symbol(Date.toISOString, Decl(lib.es5.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 35, 9)) +>toISOString : Symbol(Date.toISOString, Decl(lib.es5.d.ts, --, --)) + + // Convert from `Date` to `Temporal.Instant` + const sameInstant = date.toTemporalInstant(); // => 2019-12-31T18:30:00.123Z +>sameInstant : Symbol(sameInstant, Decl(temporal.ts, 39, 9)) +>date.toTemporalInstant : Symbol(Date.toTemporalInstant, Decl(lib.esnext.date.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 35, 9)) +>toTemporalInstant : Symbol(Date.toTemporalInstant, Decl(lib.esnext.date.d.ts, --, --)) +} + +{ + const date = new Date(2019, 11, 31, 18, 30); // => Tue Dec 31 2019 18:30:00 GMT-0800 (Pacific Standard Time) +>date : Symbol(date, Decl(temporal.ts, 43, 9)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.date.d.ts, --, --)) + + const instant = date.toTemporalInstant(); // => 2020-01-01T02:30:00Z +>instant : Symbol(instant, Decl(temporal.ts, 44, 9)) +>date.toTemporalInstant : Symbol(Date.toTemporalInstant, Decl(lib.esnext.date.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 43, 9)) +>toTemporalInstant : Symbol(Date.toTemporalInstant, Decl(lib.esnext.date.d.ts, --, --)) + + const zonedDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()); +>zonedDateTime : Symbol(zonedDateTime, Decl(temporal.ts, 45, 9)) +>instant.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 44, 9)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.timeZoneId : Symbol(Temporal.Now.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.Now.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2019-12-31T18:30:00-08:00[America/Los_Angeles] + zonedDateTime.day; // => 31 +>zonedDateTime.day : Symbol(Temporal.ZonedDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTime : Symbol(zonedDateTime, Decl(temporal.ts, 45, 9)) +>day : Symbol(Temporal.ZonedDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + const dateOnly = zonedDateTime.toPlainDate(); // => 2019-12-31 +>dateOnly : Symbol(dateOnly, Decl(temporal.ts, 48, 9)) +>zonedDateTime.toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTime : Symbol(zonedDateTime, Decl(temporal.ts, 45, 9)) +>toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const instant = new Temporal.Instant(1553906700000000000n); +>instant : Symbol(instant, Decl(temporal.ts, 52, 9)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // When was the Unix epoch? + const epoch = new Temporal.Instant(0n); // => 1970-01-01T00:00:00Z +>epoch : Symbol(epoch, Decl(temporal.ts, 54, 9)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // Dates before the Unix epoch are negative + const turnOfTheCentury = new Temporal.Instant(-2208988800000000000n); // => 1900-01-01T00:00:00Z +>turnOfTheCentury : Symbol(turnOfTheCentury, Decl(temporal.ts, 56, 9)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let instant: Temporal.Instant; +>instant : Symbol(instant, Decl(temporal.ts, 60, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]"); +>instant : Symbol(instant, Decl(temporal.ts, 60, 7)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant = Temporal.Instant.from("2019-03-30T01:45+01:00"); +>instant : Symbol(instant, Decl(temporal.ts, 60, 7)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant = Temporal.Instant.from("2019-03-30T00:45Z"); +>instant : Symbol(instant, Decl(temporal.ts, 60, 7)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant === Temporal.Instant.from(instant); // => false +>instant : Symbol(instant, Decl(temporal.ts, 60, 7)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 60, 7)) +} + +{ + const legacyDate = new Date("1995-12-17T03:24Z"); +>legacyDate : Symbol(legacyDate, Decl(temporal.ts, 68, 9)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.date.d.ts, --, --)) + + let instant: Temporal.Instant; +>instant : Symbol(instant, Decl(temporal.ts, 69, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()); // => 1995-12-17T03:24:00Z +>instant : Symbol(instant, Decl(temporal.ts, 69, 7)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>legacyDate.getTime : Symbol(Date.getTime, Decl(lib.es5.d.ts, --, --)) +>legacyDate : Symbol(legacyDate, Decl(temporal.ts, 68, 9)) +>getTime : Symbol(Date.getTime, Decl(lib.es5.d.ts, --, --)) + + instant = legacyDate.toTemporalInstant(); // recommended +>instant : Symbol(instant, Decl(temporal.ts, 69, 7)) +>legacyDate.toTemporalInstant : Symbol(Date.toTemporalInstant, Decl(lib.esnext.date.d.ts, --, --)) +>legacyDate : Symbol(legacyDate, Decl(temporal.ts, 68, 9)) +>toTemporalInstant : Symbol(Date.toTemporalInstant, Decl(lib.esnext.date.d.ts, --, --)) +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); +>one : Symbol(one, Decl(temporal.ts, 75, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); +>two : Symbol(two, Decl(temporal.ts, 76, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const three = Temporal.Instant.fromEpochMilliseconds(1.2e12); +>three : Symbol(three, Decl(temporal.ts, 77, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const sorted = [three, one, two].sort(Temporal.Instant.compare); +>sorted : Symbol(sorted, Decl(temporal.ts, 78, 9)) +>[three, one, two].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>three : Symbol(three, Decl(temporal.ts, 77, 9)) +>one : Symbol(one, Decl(temporal.ts, 75, 9)) +>two : Symbol(two, Decl(temporal.ts, 76, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.Instant.compare : Symbol(Temporal.InstantConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.InstantConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + sorted.join(" "); +>sorted.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted : Symbol(sorted, Decl(temporal.ts, 78, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) + + // => '2001-09-09T01:46:40Z 2004-11-09T11:33:20Z 2008-01-10T21:20:00Z' +} + +{ + const instant = Temporal.Instant.from("2019-03-30T00:45Z"); +>instant : Symbol(instant, Decl(temporal.ts, 84, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + new Date(instant.epochMilliseconds); // => 2019-03-30T00:45:00.000Z +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.date.d.ts, --, --)) +>instant.epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 84, 9)) +>epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // If you need epoch seconds data: + const epochSecs = Math.floor(instant.epochMilliseconds / 1000); // => 1553906700 +>epochSecs : Symbol(epochSecs, Decl(temporal.ts, 88, 9)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>instant.epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 84, 9)) +>epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const ns = instant.epochNanoseconds; +>ns : Symbol(ns, Decl(temporal.ts, 90, 9)) +>instant.epochNanoseconds : Symbol(Temporal.Instant.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 84, 9)) +>epochNanoseconds : Symbol(Temporal.Instant.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +>epochMicros : Symbol(epochMicros, Decl(temporal.ts, 91, 9)) +>ns : Symbol(ns, Decl(temporal.ts, 90, 9)) +>ns : Symbol(ns, Decl(temporal.ts, 90, 9)) +} + +{ + // Converting a specific exact time to a calendar date / wall-clock time + let timestamp: Temporal.Instant; +>timestamp : Symbol(timestamp, Decl(temporal.ts, 96, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100_000); +>timestamp : Symbol(timestamp, Decl(temporal.ts, 96, 7)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + timestamp.toZonedDateTimeISO("Europe/Berlin"); // => 2019-03-31T01:45:00+01:00[Europe/Berlin] +>timestamp.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>timestamp : Symbol(timestamp, Decl(temporal.ts, 96, 7)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + timestamp.toZonedDateTimeISO("UTC"); // => 2019-03-31T00:45:00+00:00[UTC] +>timestamp.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>timestamp : Symbol(timestamp, Decl(temporal.ts, 96, 7)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + timestamp.toZonedDateTimeISO("-08:00"); // => 2019-03-30T16:45:00-08:00[-08:00] +>timestamp.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>timestamp : Symbol(timestamp, Decl(temporal.ts, 96, 7)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + // What time was the Unix epoch (timestamp 0) in Bell Labs (Murray Hill, New Jersey, USA) in the Gregorian calendar? + const epoch = Temporal.Instant.fromEpochMilliseconds(0); +>epoch : Symbol(epoch, Decl(temporal.ts, 103, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory"); +>epoch.toZonedDateTimeISO("America/New_York").withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch : Symbol(epoch, Decl(temporal.ts, 103, 9)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1969-12-31T19:00:00-05:00[America/New_York][u-ca=gregory] + + // What time was the Unix epoch in Tokyo in the Japanese calendar? + const zdt = epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese"); +>zdt : Symbol(zdt, Decl(temporal.ts, 108, 9)) +>epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch : Symbol(epoch, Decl(temporal.ts, 103, 9)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1970-01-01T09:00:00+09:00[Asia/Tokyo][u-ca=japanese] + console.log(zdt.eraYear, zdt.era); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>zdt.eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 108, 9)) +>eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.era : Symbol(Temporal.ZonedDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 108, 9)) +>era : Symbol(Temporal.ZonedDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => '45 showa' +} + +{ + // Temporal.Instant representing five hours from now + Temporal.Now.instant().add({ hours: 5 }); +>Temporal.Now.instant().add : Symbol(Temporal.Instant.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>add : Symbol(Temporal.Instant.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 116, 32)) + + const fiveHours = Temporal.Duration.from({ hours: 5 }); +>fiveHours : Symbol(fiveHours, Decl(temporal.ts, 117, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 117, 46)) + + Temporal.Now.instant().add(fiveHours); +>Temporal.Now.instant().add : Symbol(Temporal.Instant.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>add : Symbol(Temporal.Instant.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>fiveHours : Symbol(fiveHours, Decl(temporal.ts, 117, 9)) +} + +{ + // Temporal.Instant representing this time an hour ago + Temporal.Now.instant().subtract({ hours: 1 }); +>Temporal.Now.instant().subtract : Symbol(Temporal.Instant.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>subtract : Symbol(Temporal.Instant.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 123, 37)) + + const oneHour = Temporal.Duration.from({ hours: 1 }); +>oneHour : Symbol(oneHour, Decl(temporal.ts, 124, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 124, 44)) + + Temporal.Now.instant().subtract(oneHour); +>Temporal.Now.instant().subtract : Symbol(Temporal.Instant.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>subtract : Symbol(Temporal.Instant.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneHour : Symbol(oneHour, Decl(temporal.ts, 124, 9)) +} + +{ + const startOfMoonMission = Temporal.Instant.from("1969-07-16T13:32:00Z"); +>startOfMoonMission : Symbol(startOfMoonMission, Decl(temporal.ts, 129, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const endOfMoonMission = Temporal.Instant.from("1969-07-24T16:50:35Z"); +>endOfMoonMission : Symbol(endOfMoonMission, Decl(temporal.ts, 130, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const missionLength = startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }); +>missionLength : Symbol(missionLength, Decl(temporal.ts, 131, 9)) +>startOfMoonMission.until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>startOfMoonMission : Symbol(startOfMoonMission, Decl(temporal.ts, 129, 9)) +>until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>endOfMoonMission : Symbol(endOfMoonMission, Decl(temporal.ts, 130, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 131, 70)) + + // => PT195H18M35S + missionLength.toLocaleString(); +>missionLength.toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>missionLength : Symbol(missionLength, Decl(temporal.ts, 131, 9)) +>toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + // example output: '195 hours 18 minutes 35 seconds' + + // Rounding, for example if you don't care about the minutes and seconds + const approxMissionLength = startOfMoonMission.until(endOfMoonMission, { +>approxMissionLength : Symbol(approxMissionLength, Decl(temporal.ts, 137, 9)) +>startOfMoonMission.until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>startOfMoonMission : Symbol(startOfMoonMission, Decl(temporal.ts, 129, 9)) +>until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>endOfMoonMission : Symbol(endOfMoonMission, Decl(temporal.ts, 130, 9)) + + largestUnit: "hour", +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 137, 76)) + + smallestUnit: "hour", +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 138, 28)) + + }); + // => PT195H + + // A billion (10^9) seconds since the epoch in different units + const epoch = Temporal.Instant.fromEpochMilliseconds(0); +>epoch : Symbol(epoch, Decl(temporal.ts, 144, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const billion = Temporal.Instant.fromEpochMilliseconds(1e9); +>billion : Symbol(billion, Decl(temporal.ts, 145, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + epoch.until(billion); +>epoch.until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch : Symbol(epoch, Decl(temporal.ts, 144, 9)) +>until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>billion : Symbol(billion, Decl(temporal.ts, 145, 9)) + + // => PT1000000000S + epoch.until(billion, { largestUnit: "hour" }); +>epoch.until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch : Symbol(epoch, Decl(temporal.ts, 144, 9)) +>until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>billion : Symbol(billion, Decl(temporal.ts, 145, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 148, 26)) + + // => PT277777H46M40S + const ns = epoch.until(billion, { largestUnit: "nanosecond" }); +>ns : Symbol(ns, Decl(temporal.ts, 150, 9)) +>epoch.until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch : Symbol(epoch, Decl(temporal.ts, 144, 9)) +>until : Symbol(Temporal.Instant.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>billion : Symbol(billion, Decl(temporal.ts, 145, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 150, 37)) + + // => PT1000000000S + ns.add({ nanoseconds: 1 }); +>ns.add : Symbol(Temporal.Duration.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>ns : Symbol(ns, Decl(temporal.ts, 150, 9)) +>add : Symbol(Temporal.Duration.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>nanoseconds : Symbol(nanoseconds, Decl(temporal.ts, 152, 12)) + + // => PT1000000000S + // (lost precision) + + // Calculate the difference in years, eliminating the ambiguity by + // explicitly using the corresponding calendar date in UTC: + epoch.toZonedDateTimeISO("UTC").until( +>epoch.toZonedDateTimeISO("UTC").until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>epoch : Symbol(epoch, Decl(temporal.ts, 144, 9)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) + + billion.toZonedDateTimeISO("UTC"), +>billion.toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>billion : Symbol(billion, Decl(temporal.ts, 145, 9)) +>toZonedDateTimeISO : Symbol(Temporal.Instant.toZonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + { largestUnit: "year" }, +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 160, 9)) + + ); + // => P31Y8M8DT1H46M40S +} + +{ + const instant = Temporal.Instant.from("2019-03-30T02:45:59.999999999Z"); +>instant : Symbol(instant, Decl(temporal.ts, 166, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Round to a particular unit + instant.round({ smallestUnit: "second" }); // => 2019-03-30T02:46:00Z +>instant.round : Symbol(Temporal.Instant.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 166, 9)) +>round : Symbol(Temporal.Instant.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 169, 19)) + + // Round to an increment of a unit, e.g. an hour: + instant.round({ roundingIncrement: 60, smallestUnit: "minute" }); +>instant.round : Symbol(Temporal.Instant.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 166, 9)) +>round : Symbol(Temporal.Instant.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 171, 19)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 171, 42)) + + // => 2019-03-30T03:00:00Z + // Round to the same increment but round down instead: + instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }); +>instant.round : Symbol(Temporal.Instant.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 166, 9)) +>round : Symbol(Temporal.Instant.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 174, 19)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 174, 42)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 174, 66)) + + // => 2019-03-30T02:00:00Z +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); +>one : Symbol(one, Decl(temporal.ts, 179, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); +>two : Symbol(two, Decl(temporal.ts, 180, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + one.equals(two); // => false +>one.equals : Symbol(Temporal.Instant.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 179, 9)) +>equals : Symbol(Temporal.Instant.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>two : Symbol(two, Decl(temporal.ts, 180, 9)) + + one.equals(one); // => true +>one.equals : Symbol(Temporal.Instant.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 179, 9)) +>equals : Symbol(Temporal.Instant.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 179, 9)) +} + +{ + const instant = Temporal.Instant.fromEpochMilliseconds(1574074321816); +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>Temporal.Instant.fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>fromEpochMilliseconds : Symbol(Temporal.InstantConstructor.fromEpochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant.toString(); // => '2019-11-18T10:52:01.816Z' +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant.toString({ timeZone: "UTC" }); +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 188, 22)) + + // => '2019-11-18T10:52:01.816+00:00' + instant.toString({ timeZone: "Asia/Seoul" }); +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 190, 22)) + + // => '2019-11-18T19:52:01.816+09:00' + + instant.toString({ smallestUnit: "minute" }); +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 193, 22)) + + // => '2019-11-18T10:52Z' + instant.toString({ fractionalSecondDigits: 0 }); +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 195, 22)) + + // => '2019-11-18T10:52:01Z' + instant.toString({ fractionalSecondDigits: 4 }); +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 197, 22)) + + // => '2019-11-18T10:52:01.8160Z' + instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }); +>instant.toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 186, 9)) +>toString : Symbol(Temporal.Instant.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 199, 22)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 199, 46)) + + // => '2019-11-18T10:52:02Z' +} + +{ + const instant = Temporal.Instant.from("2019-11-18T11:00:00.000Z"); +>instant : Symbol(instant, Decl(temporal.ts, 204, 9)) +>Temporal.Instant.from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Instant : Symbol(Temporal.Instant, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.InstantConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant.toLocaleString(); // example output: '2019-11-18, 3:00:00 a.m.' +>instant.toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 204, 9)) +>toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant.toLocaleString("de-DE"); // example output: '18.11.2019, 03:00:00' +>instant.toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 204, 9)) +>toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + instant.toLocaleString("de-DE", { +>instant.toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 204, 9)) +>toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + timeZone: "Europe/Berlin", +>timeZone : Symbol(timeZone, Decl(temporal.ts, 207, 37)) + + year: "numeric", +>year : Symbol(year, Decl(temporal.ts, 208, 34)) + + month: "numeric", +>month : Symbol(month, Decl(temporal.ts, 209, 24)) + + day: "numeric", +>day : Symbol(day, Decl(temporal.ts, 210, 25)) + + hour: "numeric", +>hour : Symbol(hour, Decl(temporal.ts, 211, 23)) + + minute: "numeric", +>minute : Symbol(minute, Decl(temporal.ts, 212, 24)) + + timeZoneName: "long", +>timeZoneName : Symbol(timeZoneName, Decl(temporal.ts, 213, 26)) + + }); // => '18.11.2019, 12:00 Mitteleuropäische Normalzeit' + instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { +>instant.toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(instant, Decl(temporal.ts, 204, 9)) +>toLocaleString : Symbol(Temporal.Instant.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + timeZone: "Asia/Kolkata", +>timeZone : Symbol(timeZone, Decl(temporal.ts, 216, 58)) + + }); // => '11/18/2019, 4:30:00 PM' +} + +{ + // UNIX epoch in California + new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601"); +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + // same, but shorter +} + +{ + let zdt: Temporal.ZonedDateTime; +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt = Temporal.ZonedDateTime.from({ +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + timeZone: "America/Los_Angeles", +>timeZone : Symbol(timeZone, Decl(temporal.ts, 237, 39)) + + year: 1995, +>year : Symbol(year, Decl(temporal.ts, 238, 40)) + + month: 12, +>month : Symbol(month, Decl(temporal.ts, 239, 19)) + + day: 7, +>day : Symbol(day, Decl(temporal.ts, 240, 18)) + + hour: 3, +>hour : Symbol(hour, Decl(temporal.ts, 241, 15)) + + minute: 24, +>minute : Symbol(minute, Decl(temporal.ts, 242, 16)) + + second: 30, +>second : Symbol(second, Decl(temporal.ts, 243, 19)) + + millisecond: 0, +>millisecond : Symbol(millisecond, Decl(temporal.ts, 244, 19)) + + microsecond: 3, +>microsecond : Symbol(microsecond, Decl(temporal.ts, 245, 23)) + + nanosecond: 500, +>nanosecond : Symbol(nanosecond, Decl(temporal.ts, 246, 23)) + + }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] + + // Different overflow modes + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 251, 39)) +>year : Symbol(year, Decl(temporal.ts, 251, 65)) +>month : Symbol(month, Decl(temporal.ts, 251, 77)) +>day : Symbol(day, Decl(temporal.ts, 251, 88)) +>overflow : Symbol(overflow, Decl(temporal.ts, 251, 100)) + + // => 2001-12-01T00:00:00+01:00[Europe/Paris] + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); +>zdt : Symbol(zdt, Decl(temporal.ts, 231, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 253, 39)) +>year : Symbol(year, Decl(temporal.ts, 253, 65)) +>month : Symbol(month, Decl(temporal.ts, 253, 77)) +>day : Symbol(day, Decl(temporal.ts, 253, 88)) +>overflow : Symbol(overflow, Decl(temporal.ts, 253, 100)) + + // => throws RangeError +} + +{ + const arr = [ +>arr : Symbol(arr, Decl(temporal.ts, 258, 9)) + + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ]; + const sorted = arr.sort(Temporal.ZonedDateTime.compare); +>sorted : Symbol(sorted, Decl(temporal.ts, 264, 9)) +>arr.sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(temporal.ts, 258, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.ZonedDateTime.compare : Symbol(Temporal.ZonedDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.ZonedDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + JSON.stringify(sorted, undefined, 2); +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>sorted : Symbol(sorted, Decl(temporal.ts, 264, 9)) +>undefined : Symbol(undefined) + + // => + // '[ + // "2020-02-01T12:30+01:00[Europe/Brussels]", + // "2020-02-01T12:30+00:00[Europe/London]", + // "2020-02-01T12:30-05:00[America/Toronto]", + // "2020-02-01T12:30-05:00[America/New_York]" + // ]' +} + +{ + const dt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]"); +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.year; // => 1995 +>dt.year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.month; // => 12 +>dt.month : Symbol(Temporal.ZonedDateTime.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>month : Symbol(Temporal.ZonedDateTime.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.monthCode; // => 'M12' +>dt.monthCode : Symbol(Temporal.ZonedDateTime.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>monthCode : Symbol(Temporal.ZonedDateTime.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.day; // => 7 +>dt.day : Symbol(Temporal.ZonedDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>day : Symbol(Temporal.ZonedDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.hour; // => 3 +>dt.hour : Symbol(Temporal.ZonedDateTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>hour : Symbol(Temporal.ZonedDateTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.minute; // => 24 +>dt.minute : Symbol(Temporal.ZonedDateTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>minute : Symbol(Temporal.ZonedDateTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.second; // => 30 +>dt.second : Symbol(Temporal.ZonedDateTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>second : Symbol(Temporal.ZonedDateTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.millisecond; // => 0 +>dt.millisecond : Symbol(Temporal.ZonedDateTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>millisecond : Symbol(Temporal.ZonedDateTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.microsecond; // => 3 +>dt.microsecond : Symbol(Temporal.ZonedDateTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>microsecond : Symbol(Temporal.ZonedDateTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.nanosecond; // => 500 +>dt.nanosecond : Symbol(Temporal.ZonedDateTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 276, 9)) +>nanosecond : Symbol(Temporal.ZonedDateTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 290, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const epochMs = zdt.epochMilliseconds; +>epochMs : Symbol(epochMs, Decl(temporal.ts, 291, 9)) +>zdt.epochMilliseconds : Symbol(Temporal.ZonedDateTime.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 290, 9)) +>epochMilliseconds : Symbol(Temporal.ZonedDateTime.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1580527800000 + zdt.toInstant().epochMilliseconds; +>zdt.toInstant().epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.toInstant : Symbol(Temporal.ZonedDateTime.toInstant, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 290, 9)) +>toInstant : Symbol(Temporal.ZonedDateTime.toInstant, Decl(lib.esnext.temporal.d.ts, --, --)) +>epochMilliseconds : Symbol(Temporal.Instant.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1580527800000 + const legacyDate = new Date(epochMs); +>legacyDate : Symbol(legacyDate, Decl(temporal.ts, 295, 9)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.date.d.ts, --, --)) +>epochMs : Symbol(epochMs, Decl(temporal.ts, 291, 9)) + + // => 2020-02-01T03:30:00.000Z + // (if the system time zone is America/Los_Angeles) + const epochNanos = zdt.epochNanoseconds; +>epochNanos : Symbol(epochNanos, Decl(temporal.ts, 298, 9)) +>zdt.epochNanoseconds : Symbol(Temporal.ZonedDateTime.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 290, 9)) +>epochNanoseconds : Symbol(Temporal.ZonedDateTime.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1580527800000000000n + + // If you need epoch seconds data: + const epochSecs = Math.floor(zdt.epochMilliseconds / 1000); // => 1553906700 +>epochSecs : Symbol(epochSecs, Decl(temporal.ts, 302, 9)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>zdt.epochMilliseconds : Symbol(Temporal.ZonedDateTime.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 290, 9)) +>epochMilliseconds : Symbol(Temporal.ZonedDateTime.epochMilliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1580527800 + + // If you need epoch microseconds data: + // (Note the extra check for correct floor rounding with bigints) + const ns = zdt.epochNanoseconds; +>ns : Symbol(ns, Decl(temporal.ts, 307, 9)) +>zdt.epochNanoseconds : Symbol(Temporal.ZonedDateTime.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 290, 9)) +>epochNanoseconds : Symbol(Temporal.ZonedDateTime.epochNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +>epochMicros : Symbol(epochMicros, Decl(temporal.ts, 308, 9)) +>ns : Symbol(ns, Decl(temporal.ts, 307, 9)) +>ns : Symbol(ns, Decl(temporal.ts, 307, 9)) + + // => 1580527800000000n +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + `Time zone is: ${zdt.timeZoneId}`; +>zdt.timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 'Time zone is: America/Los_Angeles' + zdt.withTimeZone("Asia/Kolkata").timeZoneId; +>zdt.withTimeZone("Asia/Kolkata").timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => Asia/Kolkata + zdt.withTimeZone("Asia/Calcutta").timeZoneId; +>zdt.withTimeZone("Asia/Calcutta").timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => Asia/Calcutta (does not follow links in the IANA Time Zone Database) + + zdt.withTimeZone("europe/paris").timeZoneId; +>zdt.withTimeZone("europe/paris").timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => Europe/Paris (normalized to match IANA Time Zone Database capitalization) + + zdt.withTimeZone("+05:00").timeZoneId; +>zdt.withTimeZone("+05:00").timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => +05:00 + zdt.withTimeZone("+05").timeZoneId; +>zdt.withTimeZone("+05").timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => +05:00 (normalized to ±HH:MM) + zdt.withTimeZone("+0500").timeZoneId; +>zdt.withTimeZone("+0500").timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 313, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.ZonedDateTime.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => +05:00 (normalized to ±HH:MM) +} + +{ + const date = Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]"); +>date : Symbol(date, Decl(temporal.ts, 333, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.era; +>date.era : Symbol(Temporal.ZonedDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 333, 9)) +>era : Symbol(Temporal.ZonedDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 'bce' + date.eraYear; +>date.eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 333, 9)) +>eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 16 + date.year; +>date.year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 333, 9)) +>year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => -15 +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 343, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1]; // => 'THU' +>zdt.dayOfWeek : Symbol(Temporal.ZonedDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 343, 9)) +>dayOfWeek : Symbol(Temporal.ZonedDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 348, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // ISO ordinal date + console.log(zdt.year, zdt.dayOfYear); // => '1995 341' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>zdt.year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 348, 9)) +>year : Symbol(Temporal.ZonedDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.dayOfYear : Symbol(Temporal.ZonedDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 348, 9)) +>dayOfYear : Symbol(Temporal.ZonedDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 354, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // ISO week date + console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek); // => '2021 52 6' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>zdt.yearOfWeek : Symbol(Temporal.ZonedDateTime.yearOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 354, 9)) +>yearOfWeek : Symbol(Temporal.ZonedDateTime.yearOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.weekOfYear : Symbol(Temporal.ZonedDateTime.weekOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 354, 9)) +>weekOfYear : Symbol(Temporal.ZonedDateTime.weekOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.dayOfWeek : Symbol(Temporal.ZonedDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 354, 9)) +>dayOfWeek : Symbol(Temporal.ZonedDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 360, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.daysInWeek; // => 7 +>zdt.daysInWeek : Symbol(Temporal.ZonedDateTime.daysInWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 360, 9)) +>daysInWeek : Symbol(Temporal.ZonedDateTime.daysInWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 366, 9)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + for (let month = 1; month <= 12; month++) { +>month : Symbol(month, Decl(temporal.ts, 367, 12)) +>month : Symbol(month, Decl(temporal.ts, 367, 12)) +>month : Symbol(month, Decl(temporal.ts, 367, 12)) + + const zdt = Temporal.Now.zonedDateTimeISO().with({ month }); +>zdt : Symbol(zdt, Decl(temporal.ts, 368, 13)) +>Temporal.Now.zonedDateTimeISO().with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 368, 58)) + + monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt); +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 366, 9)) +>zdt.daysInMonth : Symbol(Temporal.ZonedDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 368, 13)) +>daysInMonth : Symbol(Temporal.ZonedDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>(monthsByDays[zdt.daysInMonth] || []).concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 366, 9)) +>zdt.daysInMonth : Symbol(Temporal.ZonedDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 368, 13)) +>daysInMonth : Symbol(Temporal.ZonedDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 368, 13)) + } + + const strings = monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })); +>strings : Symbol(strings, Decl(temporal.ts, 372, 9)) +>monthsByDays[30].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 366, 9)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 372, 41)) +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 372, 41)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 372, 74)) + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 372, 9)) +>unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings.pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 372, 9)) +>pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) + + const format = new Intl.ListFormat("en"); +>format : Symbol(format, Decl(temporal.ts, 375, 9)) +>Intl.ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2025.intl.d.ts, --, --) ... and 1 more) +>ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : Symbol(poem, Decl(temporal.ts, 376, 9)) +>format.format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>format : Symbol(format, Decl(temporal.ts, 375, 9)) +>format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 372, 9)) + + console.log(poem); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>poem : Symbol(poem, Decl(temporal.ts, 376, 9)) +} + +{ + const zdt = Temporal.Now.zonedDateTimeISO(); +>zdt : Symbol(zdt, Decl(temporal.ts, 382, 9)) +>Temporal.Now.zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + const percent = zdt.dayOfYear / zdt.daysInYear; +>percent : Symbol(percent, Decl(temporal.ts, 383, 9)) +>zdt.dayOfYear : Symbol(Temporal.ZonedDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 382, 9)) +>dayOfYear : Symbol(Temporal.ZonedDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.daysInYear : Symbol(Temporal.ZonedDateTime.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 382, 9)) +>daysInYear : Symbol(Temporal.ZonedDateTime.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; +>percent.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>percent : Symbol(percent, Decl(temporal.ts, 383, 9)) +>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>style : Symbol(style, Decl(temporal.ts, 384, 49)) + + // example output: "The year is 10% over!" +} + +{ + const zdt = Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 389, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.monthsInYear; // => 12 +>zdt.monthsInYear : Symbol(Temporal.ZonedDateTime.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 389, 9)) +>monthsInYear : Symbol(Temporal.ZonedDateTime.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Is this year a leap year? + const zdt = Temporal.Now.zonedDateTimeISO(); +>zdt : Symbol(zdt, Decl(temporal.ts, 395, 9)) +>Temporal.Now.zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.inLeapYear; // example output: true +>zdt.inLeapYear : Symbol(Temporal.ZonedDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 395, 9)) +>inLeapYear : Symbol(Temporal.ZonedDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + zdt.with({ year: 2100 }).inLeapYear; // => false +>zdt.with({ year: 2100 }).inLeapYear : Symbol(Temporal.ZonedDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 395, 9)) +>with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 398, 14)) +>inLeapYear : Symbol(Temporal.ZonedDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 402, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.hoursInDay; // 25 +>zdt.hoursInDay : Symbol(Temporal.ZonedDateTime.hoursInDay, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 402, 9)) +>hoursInDay : Symbol(Temporal.ZonedDateTime.hoursInDay, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 407, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.offsetNanoseconds; +>zdt.offsetNanoseconds : Symbol(Temporal.ZonedDateTime.offsetNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 407, 9)) +>offsetNanoseconds : Symbol(Temporal.ZonedDateTime.offsetNanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => -25200000000000 + // (-7 * 3600 * 1e9) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 414, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.offset; +>zdt.offset : Symbol(Temporal.ZonedDateTime.offset, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 414, 9)) +>offset : Symbol(Temporal.ZonedDateTime.offset, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => '-07:00' + zdt.withTimeZone("Asia/Kolkata").offset; +>zdt.withTimeZone("Asia/Kolkata").offset : Symbol(Temporal.ZonedDateTime.offset, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 414, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>offset : Symbol(Temporal.ZonedDateTime.offset, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => '+05:30' + + const minus8Hours = "-08:00"; +>minus8Hours : Symbol(minus8Hours, Decl(temporal.ts, 420, 9)) + + const daylightTime0130 = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); +>daylightTime0130 : Symbol(daylightTime0130, Decl(temporal.ts, 421, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2020-11-01T01:30:00-07:00[America/Los_Angeles] + // This is Pacific Daylight Time 1:30AM + const repeated0130 = daylightTime0130.with({ offset: minus8Hours }); +>repeated0130 : Symbol(repeated0130, Decl(temporal.ts, 424, 9)) +>daylightTime0130.with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>daylightTime0130 : Symbol(daylightTime0130, Decl(temporal.ts, 421, 9)) +>with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>offset : Symbol(offset, Decl(temporal.ts, 424, 48)) +>minus8Hours : Symbol(minus8Hours, Decl(temporal.ts, 420, 9)) + + // => 2020-11-01T01:30:00-08:00[America/Los_Angeles] + // This is Pacific Standard Time 1:30AM +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 430, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.with({ year: 2015, minute: 31 }); // => 2015-12-07T03:31:00-06:00[America/Chicago] +>zdt.with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 430, 9)) +>with : Symbol(Temporal.ZonedDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 431, 14)) +>minute : Symbol(minute, Decl(temporal.ts, 431, 26)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 435, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00-08:00[America/Los_Angeles] +>zdt.withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 435, 9)) +>withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 436, 23)) + + const time = Temporal.PlainTime.from("11:22"); +>time : Symbol(time, Decl(temporal.ts, 437, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.withPlainTime(time); // => 2015-12-07T11:22:00-08:00[America/Los_Angeles] +>zdt.withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 435, 9)) +>withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 437, 9)) + + zdt.withPlainTime("12:34"); // => 2015-12-07T12:34:00-08:00[America/Los_Angeles] +>zdt.withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 435, 9)) +>withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) + + // easier for chaining + zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00-08:00[America/Los_Angeles] +>zdt.add({ days: 2, hours: 22 }).withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.add : Symbol(Temporal.ZonedDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 435, 9)) +>add : Symbol(Temporal.ZonedDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 442, 13)) +>hours : Symbol(hours, Decl(temporal.ts, 442, 22)) +>withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 446, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]' +>zdt.toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 446, 9)) +>toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.withTimeZone("Africa/Accra").toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]' +>zdt.withTimeZone("Africa/Accra").toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 446, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 452, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + `${zdt.era} ${zdt.eraYear}`; // => 'heisei 7' +>zdt.era : Symbol(Temporal.ZonedDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 452, 9)) +>era : Symbol(Temporal.ZonedDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 452, 9)) +>eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.withCalendar("gregory").eraYear; // => 1995 +>zdt.withCalendar("gregory").eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 452, 9)) +>withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>eraYear : Symbol(Temporal.ZonedDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 458, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Add a day to get midnight on the day after DST starts + const laterDay = zdt.add({ days: 1 }); +>laterDay : Symbol(laterDay, Decl(temporal.ts, 460, 9)) +>zdt.add : Symbol(Temporal.ZonedDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 458, 9)) +>add : Symbol(Temporal.ZonedDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 460, 30)) + + // => 2020-03-09T00:00:00-07:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + laterDay.since(zdt, { largestUnit: "hour" }).hours; +>laterDay.since(zdt, { largestUnit: "hour" }).hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +>laterDay.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>laterDay : Symbol(laterDay, Decl(temporal.ts, 460, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 458, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 463, 25)) +>hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 23 + // because one clock hour lost to DST + + const laterHours = zdt.add({ hours: 24 }); +>laterHours : Symbol(laterHours, Decl(temporal.ts, 467, 9)) +>zdt.add : Symbol(Temporal.ZonedDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 458, 9)) +>add : Symbol(Temporal.ZonedDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 467, 32)) + + // => 2020-03-09T01:00:00-07:00[America/Los_Angeles] + // Adding time units doesn't adjust for DST. Result is 1:00AM: 24 real-world + // hours later because a clock hour was skipped by DST. + laterHours.since(zdt, { largestUnit: "hour" }).hours; // => 24 +>laterHours.since(zdt, { largestUnit: "hour" }).hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +>laterHours.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>laterHours : Symbol(laterHours, Decl(temporal.ts, 467, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 458, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 471, 27)) +>hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 475, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Add a day to get midnight on the day after DST starts + const earlierDay = zdt.subtract({ days: 1 }); +>earlierDay : Symbol(earlierDay, Decl(temporal.ts, 477, 9)) +>zdt.subtract : Symbol(Temporal.ZonedDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 475, 9)) +>subtract : Symbol(Temporal.ZonedDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 477, 37)) + + // => 2020-03-08T00:00:00-08:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + earlierDay.since(zdt, { largestUnit: "hour" }).hours; +>earlierDay.since(zdt, { largestUnit: "hour" }).hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlierDay.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlierDay : Symbol(earlierDay, Decl(temporal.ts, 477, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 475, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 480, 27)) +>hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => -23 + // because one clock hour lost to DST + + const earlierHours = zdt.subtract({ hours: 24 }); +>earlierHours : Symbol(earlierHours, Decl(temporal.ts, 484, 9)) +>zdt.subtract : Symbol(Temporal.ZonedDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 475, 9)) +>subtract : Symbol(Temporal.ZonedDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 484, 39)) + + // => 2020-03-07T23:00:00-08:00[America/Los_Angeles] + // Subtracting time units doesn't adjust for DST. Result is 11:00PM: 24 real-world + // hours earlier because a clock hour was skipped by DST. + earlierHours.since(zdt, { largestUnit: "hour" }).hours; // => -24 +>earlierHours.since(zdt, { largestUnit: "hour" }).hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlierHours.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlierHours : Symbol(earlierHours, Decl(temporal.ts, 484, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 475, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 488, 29)) +>hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 492, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 493, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt1.until(zdt2); +>zdt1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 492, 9)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 493, 9)) + + // => PT202956H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "year" }); +>zdt1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 492, 9)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 493, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 496, 22)) + + // => P23Y1M24DT12H5M29.9999965S + zdt2.until(zdt1, { largestUnit: "year" }); +>zdt2.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 493, 9)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 492, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 498, 22)) + + // => -P23Y1M24DT12H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "nanosecond" }); +>zdt1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 492, 9)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 493, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 500, 22)) + + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + zdt1.until(zdt2, { smallestUnit: "second" }); +>zdt1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 492, 9)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 493, 9)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 505, 22)) + + // => PT202956H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })); +>jan1 : Symbol(jan1, Decl(temporal.ts, 509, 11)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 509, 16)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 509, 22)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 509, 45)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 509, 83)) +>month : Symbol(month, Decl(temporal.ts, 509, 95)) +>day : Symbol(day, Decl(temporal.ts, 509, 102)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 509, 110)) + + jan1.until(feb1, { largestUnit: "day" }); // => P31D +>jan1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>jan1 : Symbol(jan1, Decl(temporal.ts, 509, 11)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 509, 16)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 510, 22)) + + jan1.until(feb1, { largestUnit: "month" }); // => P1M +>jan1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>jan1 : Symbol(jan1, Decl(temporal.ts, 509, 11)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 509, 16)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 511, 22)) + + feb1.until(mar1, { largestUnit: "day" }); // => P29D +>feb1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 509, 16)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 509, 22)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 512, 22)) + + feb1.until(mar1, { largestUnit: "month" }); // => P1M +>feb1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 509, 16)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 509, 22)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 513, 22)) + + jan1.until(mar1, { largestUnit: "day" }); // => P60D +>jan1.until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>jan1 : Symbol(jan1, Decl(temporal.ts, 509, 11)) +>until : Symbol(Temporal.ZonedDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 509, 22)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 514, 22)) +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 518, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 519, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt2.since(zdt1); // => PT202956H5M29.9999965S +>zdt2.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 519, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 518, 9)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 524, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Round to a particular unit + zdt.round({ smallestUnit: "hour" }); +>zdt.round : Symbol(Temporal.ZonedDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 524, 9)) +>round : Symbol(Temporal.ZonedDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 527, 15)) + + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + // Round to an increment of a unit, e.g. half an hour: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }); +>zdt.round : Symbol(Temporal.ZonedDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 524, 9)) +>round : Symbol(Temporal.ZonedDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 530, 15)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 530, 38)) + + // => 1995-12-07T03:30:00-08:00[America/Los_Angeles] + // Round to the same increment but round down instead: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); +>zdt.round : Symbol(Temporal.ZonedDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 524, 9)) +>round : Symbol(Temporal.ZonedDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 533, 15)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 533, 38)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 533, 62)) + + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 538, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] +>zdt.startOfDay : Symbol(Temporal.ZonedDateTime.startOfDay, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 538, 9)) +>startOfDay : Symbol(Temporal.ZonedDateTime.startOfDay, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let duration: Temporal.Duration; +>duration : Symbol(duration, Decl(temporal.ts, 543, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // How long until the next offset change from now, in the current location? + const tz = Temporal.Now.timeZoneId(); +>tz : Symbol(tz, Decl(temporal.ts, 545, 9)) +>Temporal.Now.timeZoneId : Symbol(Temporal.Now.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.Now.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + const now = Temporal.Now.zonedDateTimeISO(tz); +>now : Symbol(now, Decl(temporal.ts, 546, 9)) +>Temporal.Now.zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>tz : Symbol(tz, Decl(temporal.ts, 545, 9)) + + const nextTransition = now.getTimeZoneTransition("next"); +>nextTransition : Symbol(nextTransition, Decl(temporal.ts, 547, 9)) +>now.getTimeZoneTransition : Symbol(Temporal.ZonedDateTime.getTimeZoneTransition, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>now : Symbol(now, Decl(temporal.ts, 546, 9)) +>getTimeZoneTransition : Symbol(Temporal.ZonedDateTime.getTimeZoneTransition, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + duration = nextTransition!.since(now); +>duration : Symbol(duration, Decl(temporal.ts, 543, 7)) +>nextTransition!.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>nextTransition : Symbol(nextTransition, Decl(temporal.ts, 547, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>now : Symbol(now, Decl(temporal.ts, 546, 9)) + + duration.toLocaleString(); // output will vary +>duration.toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>duration : Symbol(duration, Decl(temporal.ts, 543, 7)) +>toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + // How long until the previous offset change from now, in the current location? + const previousTransition = now.getTimeZoneTransition("previous"); +>previousTransition : Symbol(previousTransition, Decl(temporal.ts, 552, 9)) +>now.getTimeZoneTransition : Symbol(Temporal.ZonedDateTime.getTimeZoneTransition, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>now : Symbol(now, Decl(temporal.ts, 546, 9)) +>getTimeZoneTransition : Symbol(Temporal.ZonedDateTime.getTimeZoneTransition, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + duration = now.since(previousTransition!); +>duration : Symbol(duration, Decl(temporal.ts, 543, 7)) +>now.since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>now : Symbol(now, Decl(temporal.ts, 546, 9)) +>since : Symbol(Temporal.ZonedDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>previousTransition : Symbol(previousTransition, Decl(temporal.ts, 552, 9)) + + duration.toLocaleString(); // output will vary +>duration.toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>duration : Symbol(duration, Decl(temporal.ts, 543, 7)) +>toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]"); +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const zdt2 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]"); +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 559, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt1.equals(zdt2); // => false (same offset but different time zones) +>zdt1.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt2 : Symbol(zdt2, Decl(temporal.ts, 559, 9)) + + zdt1.equals(zdt1); // => true +>zdt1.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) + + // To compare time zone IDs, use withTimeZone() with each ID on the same + // ZonedDateTime instance, and use equals() to compare + const kolkata = zdt1.withTimeZone("Asia/Kolkata"); +>kolkata : Symbol(kolkata, Decl(temporal.ts, 565, 9)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")); // => true +>kolkata.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>kolkata : Symbol(kolkata, Decl(temporal.ts, 565, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Offset time zones are never equivalent to named time zones + kolkata.equals(zdt1.withTimeZone("+05:30")); // => false +>kolkata.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>kolkata : Symbol(kolkata, Decl(temporal.ts, 565, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + const zeroOffset = zdt1.withTimeZone("+00:00"); +>zeroOffset : Symbol(zeroOffset, Decl(temporal.ts, 570, 9)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + zeroOffset.equals(zdt1.withTimeZone("UTC")); // => false +>zeroOffset.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zeroOffset : Symbol(zeroOffset, Decl(temporal.ts, 570, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + // For offset time zones, any valid format is accepted + zeroOffset.equals(zdt1.withTimeZone("+00:00")); // => true +>zeroOffset.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zeroOffset : Symbol(zeroOffset, Decl(temporal.ts, 570, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + zeroOffset.equals(zdt1.withTimeZone("+0000")); // => true +>zeroOffset.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zeroOffset : Symbol(zeroOffset, Decl(temporal.ts, 570, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) + + zeroOffset.equals(zdt1.withTimeZone("+00")); // => true +>zeroOffset.equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zeroOffset : Symbol(zeroOffset, Decl(temporal.ts, 570, 9)) +>equals : Symbol(Temporal.ZonedDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt1 : Symbol(zdt1, Decl(temporal.ts, 558, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let zdt: Temporal.ZonedDateTime; +>zdt : Symbol(zdt, Decl(temporal.ts, 580, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }); +>zdt : Symbol(zdt, Decl(temporal.ts, 580, 7)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 581, 39)) +>month : Symbol(month, Decl(temporal.ts, 581, 51)) +>day : Symbol(day, Decl(temporal.ts, 581, 62)) +>hour : Symbol(hour, Decl(temporal.ts, 581, 70)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 581, 80)) + + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos]' +>zdt.toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 580, 7)) +>toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt = zdt.withCalendar("japanese"); +>zdt : Symbol(zdt, Decl(temporal.ts, 580, 7)) +>zdt.withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 580, 7)) +>withCalendar : Symbol(Temporal.ZonedDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos][u-ca=japanese]' +>zdt.toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 580, 7)) +>toString : Symbol(Temporal.ZonedDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; +>options : Symbol(options, Decl(temporal.ts, 591, 9)) +>weekday : Symbol(weekday, Decl(temporal.ts, 591, 21)) +>year : Symbol(year, Decl(temporal.ts, 591, 38)) +>month : Symbol(month, Decl(temporal.ts, 591, 55)) +>day : Symbol(day, Decl(temporal.ts, 591, 70)) +>const : Symbol(const) + + zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>options : Symbol(options, Decl(temporal.ts, 591, 9)) + + /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 593, 45)) + + // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin + zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' +>zdt.withTimeZone("Pacific/Auckland").toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>withTimeZone : Symbol(Temporal.ZonedDateTime.withTimeZone, Decl(lib.esnext.temporal.d.ts, --, --)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' +>zdt.toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 588, 9)) +>toLocaleString : Symbol(Temporal.ZonedDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]"); +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toInstant(); // => 1995-12-07T01:24:30Z +>zdt.toInstant : Symbol(Temporal.ZonedDateTime.toInstant, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>toInstant : Symbol(Temporal.ZonedDateTime.toInstant, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toPlainDateTime(); // => 1995-12-07T03:24:30 +>zdt.toPlainDateTime : Symbol(Temporal.ZonedDateTime.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>toPlainDateTime : Symbol(Temporal.ZonedDateTime.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toPlainDate(); // => 1995-12-07 +>zdt.toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toPlainTime(); // => 03:24:30 +>zdt.toPlainTime : Symbol(Temporal.ZonedDateTime.toPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>toPlainTime : Symbol(Temporal.ZonedDateTime.toPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 +>zdt.toPlainDate().toPlainYearMonth : Symbol(Temporal.PlainDate.toPlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>toPlainYearMonth : Symbol(Temporal.PlainDate.toPlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --)) + + zdt.toPlainDate().toPlainMonthDay(); // => 12-07 +>zdt.toPlainDate().toPlainMonthDay : Symbol(Temporal.PlainDate.toPlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt.toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdt : Symbol(zdt, Decl(temporal.ts, 600, 9)) +>toPlainDate : Symbol(Temporal.ZonedDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>toPlainMonthDay : Symbol(Temporal.PlainDate.toPlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Pi day in 2020 + const date = new Temporal.PlainDate(2020, 3, 14); // => 2020-03-14 +>date : Symbol(date, Decl(temporal.ts, 611, 9)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let date: Temporal.PlainDate; +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2006-08-24"); // => 2006-08-24 +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("20060824"); // => 2006-08-24 +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2006-08-24T15:43:27"); // => 2006-08-24 +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2006-08-24 + date === Temporal.PlainDate.from(date); // => false +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 615, 7)) + + date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24 +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 624, 36)) +>month : Symbol(month, Decl(temporal.ts, 624, 48)) +>day : Symbol(day, Decl(temporal.ts, 624, 58)) + + date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2006-08-24 + // same as above; Temporal.PlainDateTime has year, month, and day properties + + date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 629, 36)) +>month : Symbol(month, Decl(temporal.ts, 629, 48)) +>day : Symbol(day, Decl(temporal.ts, 629, 58)) +>calendar : Symbol(calendar, Decl(temporal.ts, 629, 66)) + + // => 2006-08-24[u-ca=islamic] + + // Different overflow modes + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 633, 36)) +>month : Symbol(month, Decl(temporal.ts, 633, 48)) +>day : Symbol(day, Decl(temporal.ts, 633, 59)) +>overflow : Symbol(overflow, Decl(temporal.ts, 633, 71)) + + // => 2001-12-01 + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 635, 36)) +>month : Symbol(month, Decl(temporal.ts, 635, 48)) +>day : Symbol(day, Decl(temporal.ts, 635, 58)) +>overflow : Symbol(overflow, Decl(temporal.ts, 635, 71)) + + // => 2001-01-31 + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 637, 36)) +>month : Symbol(month, Decl(temporal.ts, 637, 48)) +>day : Symbol(day, Decl(temporal.ts, 637, 59)) +>overflow : Symbol(overflow, Decl(temporal.ts, 637, 71)) + + // => throws + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); +>date : Symbol(date, Decl(temporal.ts, 615, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 639, 36)) +>month : Symbol(month, Decl(temporal.ts, 639, 48)) +>day : Symbol(day, Decl(temporal.ts, 639, 58)) +>overflow : Symbol(overflow, Decl(temporal.ts, 639, 71)) + + // => throws +} + +{ + const one = Temporal.PlainDate.from("2006-08-24"); +>one : Symbol(one, Decl(temporal.ts, 644, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const two = Temporal.PlainDate.from("2015-07-14"); +>two : Symbol(two, Decl(temporal.ts, 645, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const three = Temporal.PlainDate.from("1930-02-18"); +>three : Symbol(three, Decl(temporal.ts, 646, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const sorted = [one, two, three].sort(Temporal.PlainDate.compare); +>sorted : Symbol(sorted, Decl(temporal.ts, 647, 9)) +>[one, two, three].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 644, 9)) +>two : Symbol(two, Decl(temporal.ts, 645, 9)) +>three : Symbol(three, Decl(temporal.ts, 646, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.PlainDate.compare : Symbol(Temporal.PlainDateConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.PlainDateConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + sorted.join(" "); // => '1930-02-18 2006-08-24 2015-07-14' +>sorted.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted : Symbol(sorted, Decl(temporal.ts, 647, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +} + +{ + let date: Temporal.PlainDate; +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.year; // => 2006 +>date.year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.month; // => 8 +>date.month : Symbol(Temporal.PlainDate.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>month : Symbol(Temporal.PlainDate.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.monthCode; // => 'M08' +>date.monthCode : Symbol(Temporal.PlainDate.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>monthCode : Symbol(Temporal.PlainDate.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.day; // => 24 +>date.day : Symbol(Temporal.PlainDate.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>day : Symbol(Temporal.PlainDate.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]"); +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.year; // => 5779 +>date.year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.month; // => 6 +>date.month : Symbol(Temporal.PlainDate.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>month : Symbol(Temporal.PlainDate.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.monthCode; // => 'M05L' +>date.monthCode : Symbol(Temporal.PlainDate.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>monthCode : Symbol(Temporal.PlainDate.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.day; // => 18 +>date.day : Symbol(Temporal.PlainDate.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 652, 7)) +>day : Symbol(Temporal.PlainDate.day, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]"); +>date : Symbol(date, Decl(temporal.ts, 668, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.era; +>date.era : Symbol(Temporal.PlainDate.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 668, 9)) +>era : Symbol(Temporal.PlainDate.era, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 'bce' + date.eraYear; +>date.eraYear : Symbol(Temporal.PlainDate.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 668, 9)) +>eraYear : Symbol(Temporal.PlainDate.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 16 + date.year; +>date.year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 668, 9)) +>year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => -15 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 678, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1]; // => 'THU' +>date.dayOfWeek : Symbol(Temporal.PlainDate.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 678, 9)) +>dayOfWeek : Symbol(Temporal.PlainDate.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 683, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // ISO ordinal date + console.log(date.year, date.dayOfYear); // => '2006 236' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>date.year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 683, 9)) +>year : Symbol(Temporal.PlainDate.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date.dayOfYear : Symbol(Temporal.PlainDate.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 683, 9)) +>dayOfYear : Symbol(Temporal.PlainDate.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2022-01-01"); +>date : Symbol(date, Decl(temporal.ts, 689, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // ISO week date + console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek); // => '2021 52 6' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>date.yearOfWeek : Symbol(Temporal.PlainDate.yearOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 689, 9)) +>yearOfWeek : Symbol(Temporal.PlainDate.yearOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>date.weekOfYear : Symbol(Temporal.PlainDate.weekOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 689, 9)) +>weekOfYear : Symbol(Temporal.PlainDate.weekOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date.dayOfWeek : Symbol(Temporal.PlainDate.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 689, 9)) +>dayOfWeek : Symbol(Temporal.PlainDate.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 695, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.daysInWeek; // => 7 +>date.daysInWeek : Symbol(Temporal.PlainDate.daysInWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 695, 9)) +>daysInWeek : Symbol(Temporal.PlainDate.daysInWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 701, 9)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + for (let month = 1; month <= 12; month++) { +>month : Symbol(month, Decl(temporal.ts, 702, 12)) +>month : Symbol(month, Decl(temporal.ts, 702, 12)) +>month : Symbol(month, Decl(temporal.ts, 702, 12)) + + const date = Temporal.Now.plainDateISO().with({ month }); +>date : Symbol(date, Decl(temporal.ts, 703, 13)) +>Temporal.Now.plainDateISO().with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 703, 55)) + + monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date); +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 701, 9)) +>date.daysInMonth : Symbol(Temporal.PlainDate.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 703, 13)) +>daysInMonth : Symbol(Temporal.PlainDate.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>(monthsByDays[date.daysInMonth] || []).concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 701, 9)) +>date.daysInMonth : Symbol(Temporal.PlainDate.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 703, 13)) +>daysInMonth : Symbol(Temporal.PlainDate.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 703, 13)) + } + + const strings = monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })); +>strings : Symbol(strings, Decl(temporal.ts, 707, 9)) +>monthsByDays[30].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 701, 9)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 707, 41)) +>date.toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 707, 41)) +>toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 707, 76)) + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 707, 9)) +>unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings.pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 707, 9)) +>pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) + + const format = new Intl.ListFormat("en"); +>format : Symbol(format, Decl(temporal.ts, 710, 9)) +>Intl.ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2025.intl.d.ts, --, --) ... and 1 more) +>ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : Symbol(poem, Decl(temporal.ts, 711, 9)) +>format.format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>format : Symbol(format, Decl(temporal.ts, 710, 9)) +>format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 707, 9)) + + console.log(poem); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>poem : Symbol(poem, Decl(temporal.ts, 711, 9)) +} + +{ + const date = Temporal.Now.plainDateISO(); +>date : Symbol(date, Decl(temporal.ts, 717, 9)) +>Temporal.Now.plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + const percent = date.dayOfYear / date.daysInYear; +>percent : Symbol(percent, Decl(temporal.ts, 718, 9)) +>date.dayOfYear : Symbol(Temporal.PlainDate.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 717, 9)) +>dayOfYear : Symbol(Temporal.PlainDate.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date.daysInYear : Symbol(Temporal.PlainDate.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 717, 9)) +>daysInYear : Symbol(Temporal.PlainDate.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; +>percent.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>percent : Symbol(percent, Decl(temporal.ts, 718, 9)) +>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>style : Symbol(style, Decl(temporal.ts, 719, 49)) + + // example output: "The year is 10% over!" +} + +{ + const date = Temporal.PlainDate.from("1900-01-01"); +>date : Symbol(date, Decl(temporal.ts, 724, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.monthsInYear; // => 12 +>date.monthsInYear : Symbol(Temporal.PlainDate.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 724, 9)) +>monthsInYear : Symbol(Temporal.PlainDate.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Is this year a leap year? + const date = Temporal.Now.plainDateISO(); +>date : Symbol(date, Decl(temporal.ts, 730, 9)) +>Temporal.Now.plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.inLeapYear; // example output: true +>date.inLeapYear : Symbol(Temporal.PlainDate.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 730, 9)) +>inLeapYear : Symbol(Temporal.PlainDate.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + date.with({ year: 2100 }).inLeapYear; // => false +>date.with({ year: 2100 }).inLeapYear : Symbol(Temporal.PlainDate.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date.with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 730, 9)) +>with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 733, 15)) +>inLeapYear : Symbol(Temporal.PlainDate.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2006-01-24"); +>date : Symbol(date, Decl(temporal.ts, 737, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // What's the first day of this month? + date.with({ day: 1 }); // => 2006-01-01 +>date.with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 737, 9)) +>with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 739, 15)) + + // What's the last day of the next month? + const nextMonthDate = date.add({ months: 1 }); +>nextMonthDate : Symbol(nextMonthDate, Decl(temporal.ts, 741, 9)) +>date.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 737, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 741, 36)) + + nextMonthDate.with({ day: nextMonthDate.daysInMonth }); // => 2006-02-28 +>nextMonthDate.with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>nextMonthDate : Symbol(nextMonthDate, Decl(temporal.ts, 741, 9)) +>with : Symbol(Temporal.PlainDate.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 742, 24)) +>nextMonthDate.daysInMonth : Symbol(Temporal.PlainDate.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>nextMonthDate : Symbol(nextMonthDate, Decl(temporal.ts, 741, 9)) +>daysInMonth : Symbol(Temporal.PlainDate.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24[u-ca=japanese]"); +>date : Symbol(date, Decl(temporal.ts, 746, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.withCalendar("iso8601"); // => 2006-08-24 +>date.withCalendar : Symbol(Temporal.PlainDate.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 746, 9)) +>withCalendar : Symbol(Temporal.PlainDate.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let date: Temporal.PlainDate; +>date : Symbol(date, Decl(temporal.ts, 751, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 751, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.add({ years: 20, months: 4 }); // => 2026-12-24 +>date.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 751, 7)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 754, 14)) +>months : Symbol(months, Decl(temporal.ts, 754, 25)) + + date = Temporal.PlainDate.from("2019-01-31"); +>date : Symbol(date, Decl(temporal.ts, 751, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.add({ months: 1 }); // => 2019-02-28 +>date.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 751, 7)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 757, 14)) + + date.add({ months: 1 }, { overflow: "reject" }); // => throws +>date.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 751, 7)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 758, 14)) +>overflow : Symbol(overflow, Decl(temporal.ts, 758, 29)) +} + +{ + let date: Temporal.PlainDate; +>date : Symbol(date, Decl(temporal.ts, 762, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 762, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.subtract({ years: 20, months: 4 }); // => 1986-04-24 +>date.subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 762, 7)) +>subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 765, 19)) +>months : Symbol(months, Decl(temporal.ts, 765, 30)) + + date = Temporal.PlainDate.from("2019-03-31"); +>date : Symbol(date, Decl(temporal.ts, 762, 7)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.subtract({ months: 1 }); // => 2019-02-28 +>date.subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 762, 7)) +>subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 768, 19)) + + date.subtract({ months: 1 }, { overflow: "reject" }); // => throws +>date.subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 762, 7)) +>subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 769, 19)) +>overflow : Symbol(overflow, Decl(temporal.ts, 769, 34)) +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); +>earlier : Symbol(earlier, Decl(temporal.ts, 773, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const later = Temporal.PlainDate.from("2019-01-31"); +>later : Symbol(later, Decl(temporal.ts, 774, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + earlier.until(later); // => P4543D +>earlier.until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlier : Symbol(earlier, Decl(temporal.ts, 773, 9)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>later : Symbol(later, Decl(temporal.ts, 774, 9)) + + earlier.until(later, { largestUnit: "year" }); // => P12Y5M7D +>earlier.until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlier : Symbol(earlier, Decl(temporal.ts, 773, 9)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>later : Symbol(later, Decl(temporal.ts, 774, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 776, 26)) + + later.until(earlier, { largestUnit: "year" }); // => -P12Y5M7D +>later.until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>later : Symbol(later, Decl(temporal.ts, 774, 9)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlier : Symbol(earlier, Decl(temporal.ts, 773, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 777, 26)) + + // If you really need to calculate the difference between two Dates in + // hours, you can eliminate the ambiguity by explicitly choosing the + // point in time from which you want to reckon the difference. For + // example, using noon: + const noon = Temporal.PlainTime.from("12:00"); +>noon : Symbol(noon, Decl(temporal.ts, 783, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }); +>earlier.toPlainDateTime(noon).until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlier.toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlier : Symbol(earlier, Decl(temporal.ts, 773, 9)) +>toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>noon : Symbol(noon, Decl(temporal.ts, 783, 9)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>later.toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>later : Symbol(later, Decl(temporal.ts, 774, 9)) +>toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>noon : Symbol(noon, Decl(temporal.ts, 783, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 784, 70)) + + // => PT109032H + + const newyear = Temporal.PlainDate.from("2020-01-01"); +>newyear : Symbol(newyear, Decl(temporal.ts, 787, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }); +>newyear.until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>newyear : Symbol(newyear, Decl(temporal.ts, 787, 9)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 788, 33)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 788, 56)) + + // => PT0S + newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }); +>newyear.until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>newyear : Symbol(newyear, Decl(temporal.ts, 787, 9)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 790, 33)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 790, 56)) + + // => PT0S (mid-month dates rounded down to match `Temporal.PlainDateTime` behavior) + newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }); +>newyear.until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>newyear : Symbol(newyear, Decl(temporal.ts, 787, 9)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 792, 33)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 792, 56)) + + // => PT1M +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); +>earlier : Symbol(earlier, Decl(temporal.ts, 797, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const later = Temporal.PlainDate.from("2019-01-31"); +>later : Symbol(later, Decl(temporal.ts, 798, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + later.since(earlier); // => P4543D +>later.since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>later : Symbol(later, Decl(temporal.ts, 798, 9)) +>since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>earlier : Symbol(earlier, Decl(temporal.ts, 797, 9)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 803, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const other = Temporal.PlainDate.from("2019-01-31"); +>other : Symbol(other, Decl(temporal.ts, 804, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.equals(other); // => false +>date.equals : Symbol(Temporal.PlainDate.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 803, 9)) +>equals : Symbol(Temporal.PlainDate.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 804, 9)) + + date.equals(date); // => true +>date.equals : Symbol(Temporal.PlainDate.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 803, 9)) +>equals : Symbol(Temporal.PlainDate.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 803, 9)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 810, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toString(); // => '2006-08-24' +>date.toString : Symbol(Temporal.PlainDate.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 810, 9)) +>toString : Symbol(Temporal.PlainDate.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 815, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toLocaleString(); // example output: 8/24/2006 +>date.toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 815, 9)) +>toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toLocaleString("de-DE"); // example output: '24.8.2006' +>date.toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 815, 9)) +>toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toLocaleString("de-DE", { weekday: "long" }); // => 'Donnerstag' +>date.toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 815, 9)) +>toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>weekday : Symbol(weekday, Decl(temporal.ts, 818, 34)) + + date.toLocaleString("en-US-u-nu-fullwide"); // => '8/24/2006' +>date.toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 815, 9)) +>toLocaleString : Symbol(Temporal.PlainDate.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const plainDate = Temporal.PlainDate.from("2006-08-24"); +>plainDate : Symbol(plainDate, Decl(temporal.ts, 823, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const plainTime = Temporal.PlainTime.from("15:23:30.003"); +>plainTime : Symbol(plainTime, Decl(temporal.ts, 824, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }); +>plainDate.toZonedDateTime : Symbol(Temporal.PlainDate.toZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDate : Symbol(plainDate, Decl(temporal.ts, 823, 9)) +>toZonedDateTime : Symbol(Temporal.PlainDate.toZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 825, 31)) +>plainTime : Symbol(plainTime, Decl(temporal.ts, 825, 64)) + + // => 2006-08-24T15:23:30.003-07:00[America/Los_Angeles] + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }); +>plainDate.toZonedDateTime : Symbol(Temporal.PlainDate.toZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDate : Symbol(plainDate, Decl(temporal.ts, 823, 9)) +>toZonedDateTime : Symbol(Temporal.PlainDate.toZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 827, 31)) + + // => 2006-08-24T00:00:00-07:00[America/Los_Angeles] +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 832, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const time = Temporal.PlainTime.from("15:23:30.003"); +>time : Symbol(time, Decl(temporal.ts, 833, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toPlainDateTime(time); // => 2006-08-24T15:23:30.003 +>date.toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 832, 9)) +>toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 833, 9)) + + date.toPlainDateTime(); // => 2006-08-24T00:00:00 +>date.toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 832, 9)) +>toPlainDateTime : Symbol(Temporal.PlainDate.toPlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Symbol(date, Decl(temporal.ts, 839, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toPlainYearMonth(); // => 2006-08 +>date.toPlainYearMonth : Symbol(Temporal.PlainDate.toPlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 839, 9)) +>toPlainYearMonth : Symbol(Temporal.PlainDate.toPlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.toPlainMonthDay(); // => 08-24 +>date.toPlainMonthDay : Symbol(Temporal.PlainDate.toPlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 839, 9)) +>toPlainMonthDay : Symbol(Temporal.PlainDate.toPlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Leet hour + const time = new Temporal.PlainTime(13, 37); // => 13:37:00 +>time : Symbol(time, Decl(temporal.ts, 846, 9)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let time: Temporal.PlainTime; +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + time = Temporal.PlainTime.from("03:24:30"); // => 03:24:30 +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time = Temporal.PlainTime.from("032430"); // => 03:24:30 +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time = Temporal.PlainTime.from("1995-12-07T03:24:30"); // => 03:24:30 +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 03:24:30 + // (same as above; time zone is ignored) + time === Temporal.PlainTime.from(time); // => false +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 850, 7)) + + time = Temporal.PlainTime.from({ +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + hour: 19, +>hour : Symbol(hour, Decl(temporal.ts, 860, 36)) + + minute: 39, +>minute : Symbol(minute, Decl(temporal.ts, 861, 17)) + + second: 9, +>second : Symbol(second, Decl(temporal.ts, 862, 19)) + + millisecond: 68, +>millisecond : Symbol(millisecond, Decl(temporal.ts, 863, 18)) + + microsecond: 346, +>microsecond : Symbol(microsecond, Decl(temporal.ts, 864, 24)) + + nanosecond: 205, +>nanosecond : Symbol(nanosecond, Decl(temporal.ts, 865, 25)) + + }); // => 19:39:09.068346205 + time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }); // => 19:39:09 +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 868, 36)) +>minute : Symbol(minute, Decl(temporal.ts, 868, 46)) +>second : Symbol(second, Decl(temporal.ts, 868, 58)) + + time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")); +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 19:39:09 + // (same as above; Temporal.PlainDateTime has hour, minute, etc. properties) + + // Different overflow modes + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }); +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 874, 36)) +>minute : Symbol(minute, Decl(temporal.ts, 874, 46)) +>overflow : Symbol(overflow, Decl(temporal.ts, 874, 62)) + + // => 15:59:00 + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }); +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 876, 36)) +>minute : Symbol(minute, Decl(temporal.ts, 876, 46)) +>overflow : Symbol(overflow, Decl(temporal.ts, 876, 62)) + + // => 15:00:00 + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }); +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 878, 36)) +>minute : Symbol(minute, Decl(temporal.ts, 878, 46)) +>overflow : Symbol(overflow, Decl(temporal.ts, 878, 62)) + + // => throws + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }); +>time : Symbol(time, Decl(temporal.ts, 850, 7)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 880, 36)) +>minute : Symbol(minute, Decl(temporal.ts, 880, 46)) +>overflow : Symbol(overflow, Decl(temporal.ts, 880, 62)) + + // => throws +} + +{ + const one = Temporal.PlainTime.from("03:24"); +>one : Symbol(one, Decl(temporal.ts, 885, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const two = Temporal.PlainTime.from("01:24"); +>two : Symbol(two, Decl(temporal.ts, 886, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const three = Temporal.PlainTime.from("01:24:05"); +>three : Symbol(three, Decl(temporal.ts, 887, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const sorted = [one, two, three].sort(Temporal.PlainTime.compare); +>sorted : Symbol(sorted, Decl(temporal.ts, 888, 9)) +>[one, two, three].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 885, 9)) +>two : Symbol(two, Decl(temporal.ts, 886, 9)) +>three : Symbol(three, Decl(temporal.ts, 887, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.PlainTime.compare : Symbol(Temporal.PlainTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.PlainTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + sorted.join(" "); // => '01:24:00 01:24:05 03:24:00' +>sorted.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted : Symbol(sorted, Decl(temporal.ts, 888, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +} + +{ + // Backward transitions will repeat clock times + const zdtDst = Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]"); +>zdtDst : Symbol(zdtDst, Decl(temporal.ts, 894, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const zdtStandard = Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]"); +>zdtStandard : Symbol(zdtStandard, Decl(temporal.ts, 895, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // The "first" 1:45 (in Daylight Time) is earlier than the "second" 1:30 (in Standard Time) + Temporal.ZonedDateTime.compare(zdtDst, zdtStandard); // => -1 +>Temporal.ZonedDateTime.compare : Symbol(Temporal.ZonedDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.ZonedDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtDst : Symbol(zdtDst, Decl(temporal.ts, 894, 9)) +>zdtStandard : Symbol(zdtStandard, Decl(temporal.ts, 895, 9)) + + // 1:45 is later than 1:30 when looking at a wall clock + Temporal.PlainTime.compare(zdtDst, zdtStandard); // => 1 +>Temporal.PlainTime.compare : Symbol(Temporal.PlainTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.PlainTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtDst : Symbol(zdtDst, Decl(temporal.ts, 894, 9)) +>zdtStandard : Symbol(zdtStandard, Decl(temporal.ts, 895, 9)) + + // Forward transitions will skip clock times. Skipped times will be disambiguated. + const zdtBase = Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]"); +>zdtBase : Symbol(zdtBase, Decl(temporal.ts, 902, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const timeSkipped = Temporal.PlainTime.from("02:30"); +>timeSkipped : Symbol(timeSkipped, Decl(temporal.ts, 903, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const timeValid = Temporal.PlainTime.from("03:30"); +>timeValid : Symbol(timeValid, Decl(temporal.ts, 904, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const zdtSkipped = zdtBase.withPlainTime(timeSkipped); +>zdtSkipped : Symbol(zdtSkipped, Decl(temporal.ts, 905, 9)) +>zdtBase.withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtBase : Symbol(zdtBase, Decl(temporal.ts, 902, 9)) +>withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeSkipped : Symbol(timeSkipped, Decl(temporal.ts, 903, 9)) + + const zdtValid = zdtBase.withPlainTime(timeValid); +>zdtValid : Symbol(zdtValid, Decl(temporal.ts, 906, 9)) +>zdtBase.withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtBase : Symbol(zdtBase, Decl(temporal.ts, 902, 9)) +>withPlainTime : Symbol(Temporal.ZonedDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeValid : Symbol(timeValid, Decl(temporal.ts, 904, 9)) + + // The skipped time 2:30AM is disambiguated to 3:30AM, so the instants are equal + Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid); // => 0 +>Temporal.ZonedDateTime.compare : Symbol(Temporal.ZonedDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.ZonedDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>zdtSkipped : Symbol(zdtSkipped, Decl(temporal.ts, 905, 9)) +>zdtValid : Symbol(zdtValid, Decl(temporal.ts, 906, 9)) + + // 2:30 is earlier than 3:30 on a wall clock + Temporal.PlainTime.compare(timeSkipped, timeValid); // => -1 +>Temporal.PlainTime.compare : Symbol(Temporal.PlainTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.PlainTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeSkipped : Symbol(timeSkipped, Decl(temporal.ts, 903, 9)) +>timeValid : Symbol(timeValid, Decl(temporal.ts, 904, 9)) +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.hour; // => 19 +>time.hour : Symbol(Temporal.PlainTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>hour : Symbol(Temporal.PlainTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.minute; // => 39 +>time.minute : Symbol(Temporal.PlainTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>minute : Symbol(Temporal.PlainTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.second; // => 9 +>time.second : Symbol(Temporal.PlainTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>second : Symbol(Temporal.PlainTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.millisecond; // => 68 +>time.millisecond : Symbol(Temporal.PlainTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>millisecond : Symbol(Temporal.PlainTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.microsecond; // => 346 +>time.microsecond : Symbol(Temporal.PlainTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>microsecond : Symbol(Temporal.PlainTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.nanosecond; // => 205 +>time.nanosecond : Symbol(Temporal.PlainTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 914, 9)) +>nanosecond : Symbol(Temporal.PlainTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 924, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // What's the top of the next hour? + time.add({ hours: 1 }).with({ +>time.add({ hours: 1 }).with : Symbol(Temporal.PlainTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>time.add : Symbol(Temporal.PlainTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 924, 9)) +>add : Symbol(Temporal.PlainTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 926, 14)) +>with : Symbol(Temporal.PlainTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) + + minute: 0, +>minute : Symbol(minute, Decl(temporal.ts, 926, 33)) + + second: 0, +>second : Symbol(second, Decl(temporal.ts, 927, 18)) + + millisecond: 0, +>millisecond : Symbol(millisecond, Decl(temporal.ts, 928, 18)) + + microsecond: 0, +>microsecond : Symbol(microsecond, Decl(temporal.ts, 929, 23)) + + nanosecond: 0, +>nanosecond : Symbol(nanosecond, Decl(temporal.ts, 930, 23)) + + }); // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 936, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.add({ minutes: 5, nanoseconds: 800 }); // => 19:44:09.068347005 +>time.add : Symbol(Temporal.PlainTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 936, 9)) +>add : Symbol(Temporal.PlainTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 937, 14)) +>nanoseconds : Symbol(nanoseconds, Decl(temporal.ts, 937, 26)) +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 941, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.subtract({ minutes: 5, nanoseconds: 800 }); // => 19:34:09.068345405 +>time.subtract : Symbol(Temporal.PlainTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 941, 9)) +>subtract : Symbol(Temporal.PlainTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 942, 19)) +>nanoseconds : Symbol(nanoseconds, Decl(temporal.ts, 942, 31)) +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); +>time : Symbol(time, Decl(temporal.ts, 946, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.until(Temporal.PlainTime.from("22:39:09.068346205")); // => PT2H25M48.096948106S +>time.until : Symbol(Temporal.PlainTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 946, 9)) +>until : Symbol(Temporal.PlainTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.until(Temporal.PlainTime.from("19:39:09.068346205")); // => -PT34M11.903051894S +>time.until : Symbol(Temporal.PlainTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 946, 9)) +>until : Symbol(Temporal.PlainTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Rounding, for example if you don't care about sub-seconds + time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }); +>time.until : Symbol(Temporal.PlainTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 946, 9)) +>until : Symbol(Temporal.PlainTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 951, 63)) + + // => PT2H25M48S +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); +>time : Symbol(time, Decl(temporal.ts, 956, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.since(Temporal.PlainTime.from("19:39:09.068346205")); // => PT34M11.903051894S +>time.since : Symbol(Temporal.PlainTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 956, 9)) +>since : Symbol(Temporal.PlainTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.since(Temporal.PlainTime.from("22:39:09.068346205")); // => -PT2H25M48.096948106S +>time.since : Symbol(Temporal.PlainTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 956, 9)) +>since : Symbol(Temporal.PlainTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 962, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Round to a particular unit + time.round({ smallestUnit: "hour" }); // => 20:00:00 +>time.round : Symbol(Temporal.PlainTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 962, 9)) +>round : Symbol(Temporal.PlainTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 965, 16)) + + // Round to an increment of a unit, e.g. half an hour: + time.round({ roundingIncrement: 30, smallestUnit: "minute" }); +>time.round : Symbol(Temporal.PlainTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 962, 9)) +>round : Symbol(Temporal.PlainTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 967, 16)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 967, 39)) + + // => 19:30:00 + // Round to the same increment but round up instead: + time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }); +>time.round : Symbol(Temporal.PlainTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 962, 9)) +>round : Symbol(Temporal.PlainTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 970, 16)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 970, 39)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 970, 63)) + + // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 975, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const other = Temporal.PlainTime.from("20:13:20.971398099"); +>other : Symbol(other, Decl(temporal.ts, 976, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.equals(other); // => false +>time.equals : Symbol(Temporal.PlainTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 975, 9)) +>equals : Symbol(Temporal.PlainTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 976, 9)) + + time.equals(time); // => true +>time.equals : Symbol(Temporal.PlainTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 975, 9)) +>equals : Symbol(Temporal.PlainTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 975, 9)) +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 982, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.toString(); // => '19:39:09.068346205' +>time.toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 982, 9)) +>toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.toString({ smallestUnit: "minute" }); // => '19:39' +>time.toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 982, 9)) +>toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 985, 19)) + + time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09' +>time.toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 982, 9)) +>toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 986, 19)) + + time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683' +>time.toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 982, 9)) +>toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 987, 19)) + + time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }); +>time.toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 982, 9)) +>toString : Symbol(Temporal.PlainTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 988, 19)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 988, 46)) + + // => '19:39:09.06835' +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Symbol(time, Decl(temporal.ts, 993, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.toLocaleString(); // example output: '7:39:09 PM' +>time.toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 993, 9)) +>toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.toLocaleString("de-DE"); // example output: '19:39:09' +>time.toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 993, 9)) +>toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }); // => '19:39:09' +>time.toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 993, 9)) +>toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 996, 34)) + + time.toLocaleString("en-US-u-nu-fullwide-hc-h24"); // => '19:39:09' +>time.toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 993, 9)) +>toLocaleString : Symbol(Temporal.PlainTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Leet hour on pi day in 2020 + const datetime = new Temporal.PlainDateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37:00 +>datetime : Symbol(datetime, Decl(temporal.ts, 1002, 9)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30"); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("19951207T032430"); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1995-12-07T03:24:30 + // same as above; time zone is ignored + dt === Temporal.PlainDateTime.from(dt); // => false +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) + + dt = Temporal.PlainDateTime.from({ +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + year: 1995, +>year : Symbol(year, Decl(temporal.ts, 1015, 38)) + + month: 12, +>month : Symbol(month, Decl(temporal.ts, 1016, 19)) + + day: 7, +>day : Symbol(day, Decl(temporal.ts, 1017, 18)) + + hour: 3, +>hour : Symbol(hour, Decl(temporal.ts, 1018, 15)) + + minute: 24, +>minute : Symbol(minute, Decl(temporal.ts, 1019, 16)) + + second: 30, +>second : Symbol(second, Decl(temporal.ts, 1020, 19)) + + millisecond: 0, +>millisecond : Symbol(millisecond, Decl(temporal.ts, 1021, 19)) + + microsecond: 3, +>microsecond : Symbol(microsecond, Decl(temporal.ts, 1022, 23)) + + nanosecond: 500, +>nanosecond : Symbol(nanosecond, Decl(temporal.ts, 1023, 23)) + + }); // => 1995-12-07T03:24:30.0000035 + dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }); // => 1995-12-07T00:00:00 +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1026, 38)) +>month : Symbol(month, Decl(temporal.ts, 1026, 50)) +>day : Symbol(day, Decl(temporal.ts, 1026, 61)) + + dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 1995-12-07T00:00:00 + // same as above; Temporal.PlainDate has year, month, and day properties + + dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1031, 38)) +>month : Symbol(month, Decl(temporal.ts, 1031, 50)) +>day : Symbol(day, Decl(temporal.ts, 1031, 60)) +>hour : Symbol(hour, Decl(temporal.ts, 1031, 69)) +>minute : Symbol(minute, Decl(temporal.ts, 1031, 78)) +>second : Symbol(second, Decl(temporal.ts, 1031, 90)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1031, 102)) + + // => 1995-12-07T03:24:30[u-ca=hebrew] + + // Different overflow modes + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1035, 38)) +>month : Symbol(month, Decl(temporal.ts, 1035, 50)) +>day : Symbol(day, Decl(temporal.ts, 1035, 61)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1035, 73)) + + // => 2001-12-01T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1037, 38)) +>month : Symbol(month, Decl(temporal.ts, 1037, 50)) +>day : Symbol(day, Decl(temporal.ts, 1037, 60)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1037, 73)) + + // => 2001-01-31T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1039, 38)) +>month : Symbol(month, Decl(temporal.ts, 1039, 50)) +>day : Symbol(day, Decl(temporal.ts, 1039, 60)) +>hour : Symbol(hour, Decl(temporal.ts, 1039, 68)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1039, 82)) + + // => 2001-01-01T23:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1041, 38)) +>month : Symbol(month, Decl(temporal.ts, 1041, 50)) +>day : Symbol(day, Decl(temporal.ts, 1041, 60)) +>minute : Symbol(minute, Decl(temporal.ts, 1041, 68)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1041, 84)) + + // => 2001-01-01T00:59:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1043, 38)) +>month : Symbol(month, Decl(temporal.ts, 1043, 50)) +>day : Symbol(day, Decl(temporal.ts, 1043, 61)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1043, 73)) + + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1045, 38)) +>month : Symbol(month, Decl(temporal.ts, 1045, 50)) +>day : Symbol(day, Decl(temporal.ts, 1045, 60)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1045, 73)) + + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1047, 38)) +>month : Symbol(month, Decl(temporal.ts, 1047, 50)) +>day : Symbol(day, Decl(temporal.ts, 1047, 60)) +>hour : Symbol(hour, Decl(temporal.ts, 1047, 68)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1047, 82)) + + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }); +>dt : Symbol(dt, Decl(temporal.ts, 1006, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1049, 38)) +>month : Symbol(month, Decl(temporal.ts, 1049, 50)) +>day : Symbol(day, Decl(temporal.ts, 1049, 60)) +>minute : Symbol(minute, Decl(temporal.ts, 1049, 68)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1049, 84)) + + // => throws +} + +{ + const one = Temporal.PlainDateTime.from("1995-12-07T03:24"); +>one : Symbol(one, Decl(temporal.ts, 1054, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const two = Temporal.PlainDateTime.from("1995-12-07T01:24"); +>two : Symbol(two, Decl(temporal.ts, 1055, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const three = Temporal.PlainDateTime.from("2015-12-07T01:24"); +>three : Symbol(three, Decl(temporal.ts, 1056, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const sorted = [one, two, three].sort(Temporal.PlainDateTime.compare); +>sorted : Symbol(sorted, Decl(temporal.ts, 1057, 9)) +>[one, two, three].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1054, 9)) +>two : Symbol(two, Decl(temporal.ts, 1055, 9)) +>three : Symbol(three, Decl(temporal.ts, 1056, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.PlainDateTime.compare : Symbol(Temporal.PlainDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.PlainDateTimeConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + sorted.join(" "); +>sorted.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted : Symbol(sorted, Decl(temporal.ts, 1057, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) + + // => '1995-12-07T01:24:00 1995-12-07T03:24:00 2015-12-07T01:24:00' +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.year; // => 1995 +>dt.year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.month; // => 12 +>dt.month : Symbol(Temporal.PlainDateTime.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>month : Symbol(Temporal.PlainDateTime.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.monthCode; // => 'M12' +>dt.monthCode : Symbol(Temporal.PlainDateTime.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>monthCode : Symbol(Temporal.PlainDateTime.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.day; // => 7 +>dt.day : Symbol(Temporal.PlainDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>day : Symbol(Temporal.PlainDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.hour; // => 3 +>dt.hour : Symbol(Temporal.PlainDateTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>hour : Symbol(Temporal.PlainDateTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.minute; // => 24 +>dt.minute : Symbol(Temporal.PlainDateTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>minute : Symbol(Temporal.PlainDateTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.second; // => 30 +>dt.second : Symbol(Temporal.PlainDateTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>second : Symbol(Temporal.PlainDateTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.millisecond; // => 0 +>dt.millisecond : Symbol(Temporal.PlainDateTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>millisecond : Symbol(Temporal.PlainDateTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.microsecond; // => 3 +>dt.microsecond : Symbol(Temporal.PlainDateTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>microsecond : Symbol(Temporal.PlainDateTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.nanosecond; // => 500 +>dt.nanosecond : Symbol(Temporal.PlainDateTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>nanosecond : Symbol(Temporal.PlainDateTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]"); +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.year; // => 5779 +>dt.year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.month; // => 6 +>dt.month : Symbol(Temporal.PlainDateTime.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>month : Symbol(Temporal.PlainDateTime.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.monthCode; // => 'M05L' +>dt.monthCode : Symbol(Temporal.PlainDateTime.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>monthCode : Symbol(Temporal.PlainDateTime.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.day; // => 18 +>dt.day : Symbol(Temporal.PlainDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>day : Symbol(Temporal.PlainDateTime.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.hour; // => 3 +>dt.hour : Symbol(Temporal.PlainDateTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>hour : Symbol(Temporal.PlainDateTime.hour, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.minute; // => 24 +>dt.minute : Symbol(Temporal.PlainDateTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>minute : Symbol(Temporal.PlainDateTime.minute, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.second; // => 30 +>dt.second : Symbol(Temporal.PlainDateTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>second : Symbol(Temporal.PlainDateTime.second, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.millisecond; // => 0 +>dt.millisecond : Symbol(Temporal.PlainDateTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>millisecond : Symbol(Temporal.PlainDateTime.millisecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.microsecond; // => 3 +>dt.microsecond : Symbol(Temporal.PlainDateTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>microsecond : Symbol(Temporal.PlainDateTime.microsecond, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.nanosecond; // => 500 +>dt.nanosecond : Symbol(Temporal.PlainDateTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1063, 7)) +>nanosecond : Symbol(Temporal.PlainDateTime.nanosecond, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const date = Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]"); +>date : Symbol(date, Decl(temporal.ts, 1091, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + date.era; +>date.era : Symbol(Temporal.PlainDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 1091, 9)) +>era : Symbol(Temporal.PlainDateTime.era, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 'bce' + date.eraYear; +>date.eraYear : Symbol(Temporal.PlainDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 1091, 9)) +>eraYear : Symbol(Temporal.PlainDateTime.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 16 + date.year; +>date.year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>date : Symbol(date, Decl(temporal.ts, 1091, 9)) +>year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => -15 +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1101, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1]; // => 'THU' +>dt.dayOfWeek : Symbol(Temporal.PlainDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1101, 9)) +>dayOfWeek : Symbol(Temporal.PlainDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1106, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // ISO ordinal date + console.log(dt.year, dt.dayOfYear); // => '1995 341' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>dt.year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1106, 9)) +>year : Symbol(Temporal.PlainDateTime.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.dayOfYear : Symbol(Temporal.PlainDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1106, 9)) +>dayOfYear : Symbol(Temporal.PlainDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const dt = Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1112, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // ISO week date + console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek); // => '2021 52 6' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>dt.yearOfWeek : Symbol(Temporal.PlainDateTime.yearOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1112, 9)) +>yearOfWeek : Symbol(Temporal.PlainDateTime.yearOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.weekOfYear : Symbol(Temporal.PlainDateTime.weekOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1112, 9)) +>weekOfYear : Symbol(Temporal.PlainDateTime.weekOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.dayOfWeek : Symbol(Temporal.PlainDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1112, 9)) +>dayOfWeek : Symbol(Temporal.PlainDateTime.dayOfWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1118, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.daysInWeek; // => 7 +>dt.daysInWeek : Symbol(Temporal.PlainDateTime.daysInWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1118, 9)) +>daysInWeek : Symbol(Temporal.PlainDateTime.daysInWeek, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1124, 9)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + for (let month = 1; month <= 12; month++) { +>month : Symbol(month, Decl(temporal.ts, 1125, 12)) +>month : Symbol(month, Decl(temporal.ts, 1125, 12)) +>month : Symbol(month, Decl(temporal.ts, 1125, 12)) + + const dt = Temporal.Now.plainDateTimeISO().with({ month }); +>dt : Symbol(dt, Decl(temporal.ts, 1126, 13)) +>Temporal.Now.plainDateTimeISO().with : Symbol(Temporal.PlainDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now.plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>with : Symbol(Temporal.PlainDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1126, 57)) + + monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt); +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1124, 9)) +>dt.daysInMonth : Symbol(Temporal.PlainDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1126, 13)) +>daysInMonth : Symbol(Temporal.PlainDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>(monthsByDays[dt.daysInMonth] || []).concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1124, 9)) +>dt.daysInMonth : Symbol(Temporal.PlainDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1126, 13)) +>daysInMonth : Symbol(Temporal.PlainDateTime.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1126, 13)) + } + + const strings = monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })); +>strings : Symbol(strings, Decl(temporal.ts, 1130, 9)) +>monthsByDays[30].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1124, 9)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1130, 41)) +>dt.toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1130, 41)) +>toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1130, 72)) + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 1130, 9)) +>unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings.pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 1130, 9)) +>pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) + + const format = new Intl.ListFormat("en"); +>format : Symbol(format, Decl(temporal.ts, 1133, 9)) +>Intl.ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2025.intl.d.ts, --, --) ... and 1 more) +>ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : Symbol(poem, Decl(temporal.ts, 1134, 9)) +>format.format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>format : Symbol(format, Decl(temporal.ts, 1133, 9)) +>format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 1130, 9)) + + console.log(poem); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>poem : Symbol(poem, Decl(temporal.ts, 1134, 9)) +} + +{ + const dt = Temporal.Now.plainDateTimeISO(); +>dt : Symbol(dt, Decl(temporal.ts, 1140, 9)) +>Temporal.Now.plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + const percent = dt.dayOfYear / dt.daysInYear; +>percent : Symbol(percent, Decl(temporal.ts, 1141, 9)) +>dt.dayOfYear : Symbol(Temporal.PlainDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1140, 9)) +>dayOfYear : Symbol(Temporal.PlainDateTime.dayOfYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.daysInYear : Symbol(Temporal.PlainDateTime.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1140, 9)) +>daysInYear : Symbol(Temporal.PlainDateTime.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; +>percent.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>percent : Symbol(percent, Decl(temporal.ts, 1141, 9)) +>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>style : Symbol(style, Decl(temporal.ts, 1142, 49)) + + // example output: "The year is 10% over!" +} + +{ + const dt = Temporal.PlainDate.from("1900-01-01T12:00"); +>dt : Symbol(dt, Decl(temporal.ts, 1147, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.monthsInYear; // => 12 +>dt.monthsInYear : Symbol(Temporal.PlainDate.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1147, 9)) +>monthsInYear : Symbol(Temporal.PlainDate.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Is this year a leap year? + const dt = Temporal.Now.plainDateTimeISO(); +>dt : Symbol(dt, Decl(temporal.ts, 1153, 9)) +>Temporal.Now.plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.inLeapYear; // example output: true +>dt.inLeapYear : Symbol(Temporal.PlainDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1153, 9)) +>inLeapYear : Symbol(Temporal.PlainDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + dt.with({ year: 2100 }).inLeapYear; // => false +>dt.with({ year: 2100 }).inLeapYear : Symbol(Temporal.PlainDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.with : Symbol(Temporal.PlainDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1153, 9)) +>with : Symbol(Temporal.PlainDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1156, 13)) +>inLeapYear : Symbol(Temporal.PlainDateTime.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1160, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035 +>dt.with : Symbol(Temporal.PlainDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1160, 9)) +>with : Symbol(Temporal.PlainDateTime.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1161, 13)) +>second : Symbol(second, Decl(temporal.ts, 1161, 25)) +} + +{ + const dt = Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1165, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00 +>dt.withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1165, 9)) +>withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 1166, 22)) + + const time = Temporal.PlainTime.from("11:22"); +>time : Symbol(time, Decl(temporal.ts, 1167, 9)) +>Temporal.PlainTime.from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainTime : Symbol(Temporal.PlainTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.withPlainTime(time); // => 2015-12-07T11:22:00 +>dt.withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1165, 9)) +>withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>time : Symbol(time, Decl(temporal.ts, 1167, 9)) + + dt.withPlainTime("12:34"); // => 2015-12-07T12:34:00 +>dt.withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1165, 9)) +>withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) + + // easier for chaining + dt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00 +>dt.add({ days: 2, hours: 22 }).withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1165, 9)) +>add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1172, 12)) +>hours : Symbol(hours, Decl(temporal.ts, 1172, 21)) +>withPlainTime : Symbol(Temporal.PlainDateTime.withPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]"); +>dt : Symbol(dt, Decl(temporal.ts, 1176, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.withCalendar("iso8601"); // => 1995-12-07T03:24:30.0000035 +>dt.withCalendar : Symbol(Temporal.PlainDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1176, 9)) +>withCalendar : Symbol(Temporal.PlainDateTime.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Symbol(dt, Decl(temporal.ts, 1181, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1181, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.add({ years: 20, months: 4, nanoseconds: 500 }); // => 2016-04-07T03:24:30.000004 +>dt.add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1181, 7)) +>add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1184, 12)) +>months : Symbol(months, Decl(temporal.ts, 1184, 23)) +>nanoseconds : Symbol(nanoseconds, Decl(temporal.ts, 1184, 34)) + + dt = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt : Symbol(dt, Decl(temporal.ts, 1181, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.add({ months: 1 }); // => 2019-02-28T15:30:00 +>dt.add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1181, 7)) +>add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1187, 12)) + + dt.add({ months: 1 }, { overflow: "reject" }); // => throws +>dt.add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1181, 7)) +>add : Symbol(Temporal.PlainDateTime.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1188, 12)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1188, 27)) +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Symbol(dt, Decl(temporal.ts, 1192, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1192, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.subtract({ years: 20, months: 4, nanoseconds: 500 }); // => 1975-08-07T03:24:30.000003 +>dt.subtract : Symbol(Temporal.PlainDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1192, 7)) +>subtract : Symbol(Temporal.PlainDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1195, 17)) +>months : Symbol(months, Decl(temporal.ts, 1195, 28)) +>nanoseconds : Symbol(nanoseconds, Decl(temporal.ts, 1195, 39)) + + dt = Temporal.PlainDateTime.from("2019-03-31T15:30"); +>dt : Symbol(dt, Decl(temporal.ts, 1192, 7)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.subtract({ months: 1 }); // => 2019-02-28T15:30:00 +>dt.subtract : Symbol(Temporal.PlainDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1192, 7)) +>subtract : Symbol(Temporal.PlainDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1198, 17)) + + dt.subtract({ months: 1 }, { overflow: "reject" }); // => throws +>dt.subtract : Symbol(Temporal.PlainDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1192, 7)) +>subtract : Symbol(Temporal.PlainDateTime.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1199, 17)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1199, 32)) +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt1 : Symbol(dt1, Decl(temporal.ts, 1203, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt2 : Symbol(dt2, Decl(temporal.ts, 1204, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt1.until(dt2); +>dt1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1203, 9)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1204, 9)) + + // => P8456DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "year" }); +>dt1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1203, 9)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1204, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1207, 20)) + + // => P23Y1M24DT12H5M29.9999965S + dt2.until(dt1, { largestUnit: "year" }); +>dt2.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1204, 9)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1203, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1209, 20)) + + // => -P23Y1M24DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "nanosecond" }); +>dt1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1203, 9)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1204, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1211, 20)) + + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + dt1.until(dt2, { smallestUnit: "second" }); +>dt1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1203, 9)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1204, 9)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1216, 20)) + + // => P8456DT12H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })); +>jan1 : Symbol(jan1, Decl(temporal.ts, 1220, 11)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 1220, 16)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 1220, 22)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1220, 45)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1220, 83)) +>month : Symbol(month, Decl(temporal.ts, 1220, 95)) +>day : Symbol(day, Decl(temporal.ts, 1220, 102)) + + jan1.until(feb1); // => P31D +>jan1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>jan1 : Symbol(jan1, Decl(temporal.ts, 1220, 11)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 1220, 16)) + + jan1.until(feb1, { largestUnit: "month" }); // => P1M +>jan1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>jan1 : Symbol(jan1, Decl(temporal.ts, 1220, 11)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 1220, 16)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1222, 22)) + + feb1.until(mar1); // => P29D +>feb1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 1220, 16)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 1220, 22)) + + feb1.until(mar1, { largestUnit: "month" }); // => P1M +>feb1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>feb1 : Symbol(feb1, Decl(temporal.ts, 1220, 16)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 1220, 22)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1224, 22)) + + jan1.until(mar1); // => P60D +>jan1.until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>jan1 : Symbol(jan1, Decl(temporal.ts, 1220, 11)) +>until : Symbol(Temporal.PlainDateTime.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>mar1 : Symbol(mar1, Decl(temporal.ts, 1220, 22)) +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt1 : Symbol(dt1, Decl(temporal.ts, 1229, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt2 : Symbol(dt2, Decl(temporal.ts, 1230, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt2.since(dt1); // => P8456DT12H5M29.9999965S +>dt2.since : Symbol(Temporal.PlainDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1230, 9)) +>since : Symbol(Temporal.PlainDateTime.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1229, 9)) +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1235, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Round to a particular unit + dt.round({ smallestUnit: "hour" }); // => 1995-12-07T03:00:00 +>dt.round : Symbol(Temporal.PlainDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1235, 9)) +>round : Symbol(Temporal.PlainDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1238, 14)) + + // Round to an increment of a unit, e.g. half an hour: + dt.round({ roundingIncrement: 30, smallestUnit: "minute" }); +>dt.round : Symbol(Temporal.PlainDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1235, 9)) +>round : Symbol(Temporal.PlainDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 1240, 14)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1240, 37)) + + // => 1995-12-07T03:30:00 + // Round to the same increment but round down instead: + dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); +>dt.round : Symbol(Temporal.PlainDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1235, 9)) +>round : Symbol(Temporal.PlainDateTime.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 1243, 14)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1243, 37)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 1243, 61)) + + // => 1995-12-07T03:00:00 +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt1 : Symbol(dt1, Decl(temporal.ts, 1248, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt2 : Symbol(dt2, Decl(temporal.ts, 1249, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt1.equals(dt2); // => false +>dt1.equals : Symbol(Temporal.PlainDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1248, 9)) +>equals : Symbol(Temporal.PlainDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt2 : Symbol(dt2, Decl(temporal.ts, 1249, 9)) + + dt1.equals(dt1); // => true +>dt1.equals : Symbol(Temporal.PlainDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1248, 9)) +>equals : Symbol(Temporal.PlainDateTime.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt1 : Symbol(dt1, Decl(temporal.ts, 1248, 9)) +} + +{ + const dt = Temporal.PlainDateTime.from({ +>dt : Symbol(dt, Decl(temporal.ts, 1255, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + year: 1999, +>year : Symbol(year, Decl(temporal.ts, 1255, 44)) + + month: 12, +>month : Symbol(month, Decl(temporal.ts, 1256, 19)) + + day: 31, +>day : Symbol(day, Decl(temporal.ts, 1257, 18)) + + hour: 23, +>hour : Symbol(hour, Decl(temporal.ts, 1258, 16)) + + minute: 59, +>minute : Symbol(minute, Decl(temporal.ts, 1259, 17)) + + second: 59, +>second : Symbol(second, Decl(temporal.ts, 1260, 19)) + + millisecond: 999, +>millisecond : Symbol(millisecond, Decl(temporal.ts, 1261, 19)) + + microsecond: 999, +>microsecond : Symbol(microsecond, Decl(temporal.ts, 1262, 25)) + + nanosecond: 999, +>nanosecond : Symbol(nanosecond, Decl(temporal.ts, 1263, 25)) + + }); + dt.toString(); // => '1999-12-31T23:59:59.999999999' +>dt.toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1255, 9)) +>toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toString({ smallestUnit: "minute" }); // => '1999-12-31T23:59' +>dt.toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1255, 9)) +>toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1268, 17)) + + dt.toString({ fractionalSecondDigits: 0 }); // => '1999-12-31T23:59:59' +>dt.toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1255, 9)) +>toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 1269, 17)) + + dt.toString({ fractionalSecondDigits: 4 }); // => '1999-12-31T23:59:59.9999' +>dt.toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1255, 9)) +>toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 1270, 17)) + + dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); +>dt.toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1255, 9)) +>toString : Symbol(Temporal.PlainDateTime.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 1271, 17)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 1271, 44)) + + // => '2000-01-01T00:00:00.00000000' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1276, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toLocaleString(); // example output: 1995-12-07, 3:24:30 a.m. +>dt.toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1276, 9)) +>toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toLocaleString("de-DE"); // example output: 7.12.1995, 03:24:30 +>dt.toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1276, 9)) +>toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }); // => 'Donnerstag' +>dt.toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1276, 9)) +>toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZone : Symbol(timeZone, Decl(temporal.ts, 1279, 32)) +>weekday : Symbol(weekday, Decl(temporal.ts, 1279, 59)) + + dt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/7/1995, 3:24:30 AM' +>dt.toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1276, 9)) +>toLocaleString : Symbol(Temporal.PlainDateTime.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Symbol(dt, Decl(temporal.ts, 1284, 9)) +>Temporal.PlainDateTime.from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDateTime : Symbol(Temporal.PlainDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toPlainDate(); // => 1995-12-07 +>dt.toPlainDate : Symbol(Temporal.PlainDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1284, 9)) +>toPlainDate : Symbol(Temporal.PlainDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toPlainTime(); // => 03:24:30.0000035 +>dt.toPlainTime : Symbol(Temporal.PlainDateTime.toPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1284, 9)) +>toPlainTime : Symbol(Temporal.PlainDateTime.toPlainTime, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toPlainDate().toPlainYearMonth(); // => 1995-12 +>dt.toPlainDate().toPlainYearMonth : Symbol(Temporal.PlainDate.toPlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.toPlainDate : Symbol(Temporal.PlainDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1284, 9)) +>toPlainDate : Symbol(Temporal.PlainDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>toPlainYearMonth : Symbol(Temporal.PlainDate.toPlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --)) + + dt.toPlainDate().toPlainMonthDay(); // => 12-07 +>dt.toPlainDate().toPlainMonthDay : Symbol(Temporal.PlainDate.toPlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt.toPlainDate : Symbol(Temporal.PlainDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>dt : Symbol(dt, Decl(temporal.ts, 1284, 9)) +>toPlainDate : Symbol(Temporal.PlainDateTime.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>toPlainMonthDay : Symbol(Temporal.PlainDate.toPlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // The June 2019 meeting + const ym = new Temporal.PlainYearMonth(2019, 6); +>ym : Symbol(ym, Decl(temporal.ts, 1293, 9)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2019-06 +} + +{ + let ym: Temporal.PlainYearMonth; +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + ym = Temporal.PlainYearMonth.from("2019-06"); // => 2019-06 +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym = Temporal.PlainYearMonth.from("2019-06-24"); // => 2019-06 +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27"); // => 2019-06 +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]"); +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2019-06 + ym === Temporal.PlainYearMonth.from(ym); // => false +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) + + ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }); // => 2019-06 +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1307, 39)) +>month : Symbol(month, Decl(temporal.ts, 1307, 51)) + + ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")); +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 2019-06 + // (same as above; Temporal.PlainDate has year and month properties) + + // Different overflow modes + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }); +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1313, 39)) +>month : Symbol(month, Decl(temporal.ts, 1313, 51)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1313, 66)) + + // => 2001-12 + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }); +>ym : Symbol(ym, Decl(temporal.ts, 1298, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1315, 39)) +>month : Symbol(month, Decl(temporal.ts, 1315, 51)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1315, 66)) + + // => throws +} + +{ + const one = Temporal.PlainYearMonth.from("2006-08"); +>one : Symbol(one, Decl(temporal.ts, 1320, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const two = Temporal.PlainYearMonth.from("2015-07"); +>two : Symbol(two, Decl(temporal.ts, 1321, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const three = Temporal.PlainYearMonth.from("1930-02"); +>three : Symbol(three, Decl(temporal.ts, 1322, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const sorted = [one, two, three].sort(Temporal.PlainYearMonth.compare); +>sorted : Symbol(sorted, Decl(temporal.ts, 1323, 9)) +>[one, two, three].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1320, 9)) +>two : Symbol(two, Decl(temporal.ts, 1321, 9)) +>three : Symbol(three, Decl(temporal.ts, 1322, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.PlainYearMonth.compare : Symbol(Temporal.PlainYearMonthConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.PlainYearMonthConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + sorted.join(" "); // => '1930-02 2006-08 2015-07' +>sorted.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted : Symbol(sorted, Decl(temporal.ts, 1323, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +} + +{ + let ym: Temporal.PlainYearMonth; +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.year; // => 2019 +>ym.year : Symbol(Temporal.PlainYearMonth.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>year : Symbol(Temporal.PlainYearMonth.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.month; // => 6 +>ym.month : Symbol(Temporal.PlainYearMonth.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>month : Symbol(Temporal.PlainYearMonth.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.monthCode; // => 'M06' +>ym.monthCode : Symbol(Temporal.PlainYearMonth.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>monthCode : Symbol(Temporal.PlainYearMonth.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]"); +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.year; // => 5779 +>ym.year : Symbol(Temporal.PlainYearMonth.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>year : Symbol(Temporal.PlainYearMonth.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.month; // => 6 +>ym.month : Symbol(Temporal.PlainYearMonth.month, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>month : Symbol(Temporal.PlainYearMonth.month, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.monthCode; // => 'M05L' +>ym.monthCode : Symbol(Temporal.PlainYearMonth.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1328, 7)) +>monthCode : Symbol(Temporal.PlainYearMonth.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const ym = Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]"); +>ym : Symbol(ym, Decl(temporal.ts, 1342, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.era; +>ym.era : Symbol(Temporal.PlainYearMonth.era, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1342, 9)) +>era : Symbol(Temporal.PlainYearMonth.era, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 'bce' + ym.eraYear; +>ym.eraYear : Symbol(Temporal.PlainYearMonth.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1342, 9)) +>eraYear : Symbol(Temporal.PlainYearMonth.eraYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 16 + ym.year; +>ym.year : Symbol(Temporal.PlainYearMonth.year, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1342, 9)) +>year : Symbol(Temporal.PlainYearMonth.year, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => -15 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1353, 9)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + for (let month = 1; month <= 12; month++) { +>month : Symbol(month, Decl(temporal.ts, 1354, 12)) +>month : Symbol(month, Decl(temporal.ts, 1354, 12)) +>month : Symbol(month, Decl(temporal.ts, 1354, 12)) + + const ym = Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }); +>ym : Symbol(ym, Decl(temporal.ts, 1355, 13)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1355, 49)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1355, 61)) +>month : Symbol(month, Decl(temporal.ts, 1355, 82)) + + monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym); +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1353, 9)) +>ym.daysInMonth : Symbol(Temporal.PlainYearMonth.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1355, 13)) +>daysInMonth : Symbol(Temporal.PlainYearMonth.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>(monthsByDays[ym.daysInMonth] || []).concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1353, 9)) +>ym.daysInMonth : Symbol(Temporal.PlainYearMonth.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1355, 13)) +>daysInMonth : Symbol(Temporal.PlainYearMonth.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1355, 13)) + } + + const strings = monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })); +>strings : Symbol(strings, Decl(temporal.ts, 1359, 9)) +>monthsByDays[30].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>monthsByDays : Symbol(monthsByDays, Decl(temporal.ts, 1353, 9)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1359, 41)) +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1359, 41)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1359, 72)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1359, 87)) + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 1359, 9)) +>unshift : Symbol(Array.unshift, Decl(lib.es5.d.ts, --, --)) +>strings.pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 1359, 9)) +>pop : Symbol(Array.pop, Decl(lib.es5.d.ts, --, --)) + + const format = new Intl.ListFormat("en"); +>format : Symbol(format, Decl(temporal.ts, 1362, 9)) +>Intl.ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2025.intl.d.ts, --, --) ... and 1 more) +>ListFormat : Symbol(Intl.ListFormat, Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : Symbol(poem, Decl(temporal.ts, 1363, 9)) +>format.format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>format : Symbol(format, Decl(temporal.ts, 1362, 9)) +>format : Symbol(Intl.ListFormat.format, Decl(lib.es2021.intl.d.ts, --, --)) +>strings : Symbol(strings, Decl(temporal.ts, 1359, 9)) + + console.log(poem); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>poem : Symbol(poem, Decl(temporal.ts, 1363, 9)) +} + +{ + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }); +>ym : Symbol(ym, Decl(temporal.ts, 1369, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1369, 45)) +>month : Symbol(month, Decl(temporal.ts, 1369, 57)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1369, 67)) + + const percent = ym.daysInMonth / ym.daysInYear; +>percent : Symbol(percent, Decl(temporal.ts, 1370, 9)) +>ym.daysInMonth : Symbol(Temporal.PlainYearMonth.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1369, 9)) +>daysInMonth : Symbol(Temporal.PlainYearMonth.daysInMonth, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym.daysInYear : Symbol(Temporal.PlainYearMonth.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1369, 9)) +>daysInYear : Symbol(Temporal.PlainYearMonth.daysInYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + `${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!`; +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1369, 9)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1371, 32)) +>year : Symbol(year, Decl(temporal.ts, 1371, 47)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1371, 64)) +>percent.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>percent : Symbol(percent, Decl(temporal.ts, 1370, 9)) +>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --)) +>style : Symbol(style, Decl(temporal.ts, 1371, 125)) + + // => 'June 2019 was 8% of the year!' +} + +{ + const ym = Temporal.PlainYearMonth.from("1900-01"); +>ym : Symbol(ym, Decl(temporal.ts, 1376, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.monthsInYear; // => 12 +>ym.monthsInYear : Symbol(Temporal.PlainYearMonth.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1376, 9)) +>monthsInYear : Symbol(Temporal.PlainYearMonth.monthsInYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + // Was June 2019 in a leap year? + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1382, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.inLeapYear; // => false +>ym.inLeapYear : Symbol(Temporal.PlainYearMonth.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1382, 9)) +>inLeapYear : Symbol(Temporal.PlainYearMonth.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + ym.with({ year: 2100 }).inLeapYear; // => false +>ym.with({ year: 2100 }).inLeapYear : Symbol(Temporal.PlainYearMonth.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym.with : Symbol(Temporal.PlainYearMonth.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1382, 9)) +>with : Symbol(Temporal.PlainYearMonth.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1385, 13)) +>inLeapYear : Symbol(Temporal.PlainYearMonth.inLeapYear, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1389, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Get December of that year + ym.with({ month: 12 }); // => 2019-12 +>ym.with : Symbol(Temporal.PlainYearMonth.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1389, 9)) +>with : Symbol(Temporal.PlainYearMonth.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1391, 13)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1395, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.add({ years: 20, months: 4 }); // => 2039-10 +>ym.add : Symbol(Temporal.PlainYearMonth.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1395, 9)) +>add : Symbol(Temporal.PlainYearMonth.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1396, 12)) +>months : Symbol(months, Decl(temporal.ts, 1396, 23)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1400, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.subtract({ years: 20, months: 4 }); // => 1999-02 +>ym.subtract : Symbol(Temporal.PlainYearMonth.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1400, 9)) +>subtract : Symbol(Temporal.PlainYearMonth.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1401, 17)) +>months : Symbol(months, Decl(temporal.ts, 1401, 28)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2006-08"); +>ym : Symbol(ym, Decl(temporal.ts, 1405, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const other = Temporal.PlainYearMonth.from("2019-06"); +>other : Symbol(other, Decl(temporal.ts, 1406, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.until(other); // => P12Y10M +>ym.until : Symbol(Temporal.PlainYearMonth.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1405, 9)) +>until : Symbol(Temporal.PlainYearMonth.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 1406, 9)) + + ym.until(other, { largestUnit: "month" }); // => P154M +>ym.until : Symbol(Temporal.PlainYearMonth.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1405, 9)) +>until : Symbol(Temporal.PlainYearMonth.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 1406, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1408, 21)) + + other.until(ym, { largestUnit: "month" }); // => -P154M +>other.until : Symbol(Temporal.PlainYearMonth.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 1406, 9)) +>until : Symbol(Temporal.PlainYearMonth.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1405, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1409, 21)) + + // If you really need to calculate the difference between two YearMonths + // in days, you can eliminate the ambiguity by explicitly choosing the + // day of the month (and if applicable, the time of that day) from which + // you want to reckon the difference. For example, using the first of + // the month to calculate a number of days: + ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }); // => P4687D +>ym.toPlainDate({ day: 1 }).until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym.toPlainDate : Symbol(Temporal.PlainYearMonth.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1405, 9)) +>toPlainDate : Symbol(Temporal.PlainYearMonth.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 1416, 20)) +>until : Symbol(Temporal.PlainDate.until, Decl(lib.esnext.temporal.d.ts, --, --)) +>other.toPlainDate : Symbol(Temporal.PlainYearMonth.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 1406, 9)) +>toPlainDate : Symbol(Temporal.PlainYearMonth.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 1416, 56)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1416, 69)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1420, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const other = Temporal.PlainYearMonth.from("2006-08"); +>other : Symbol(other, Decl(temporal.ts, 1421, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.since(other); // => P12Y10M +>ym.since : Symbol(Temporal.PlainYearMonth.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1420, 9)) +>since : Symbol(Temporal.PlainYearMonth.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 1421, 9)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1426, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const other = Temporal.PlainYearMonth.from("2006-08"); +>other : Symbol(other, Decl(temporal.ts, 1427, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.equals(other); // => false +>ym.equals : Symbol(Temporal.PlainYearMonth.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1426, 9)) +>equals : Symbol(Temporal.PlainYearMonth.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>other : Symbol(other, Decl(temporal.ts, 1427, 9)) + + ym.equals(ym); // => true +>ym.equals : Symbol(Temporal.PlainYearMonth.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1426, 9)) +>equals : Symbol(Temporal.PlainYearMonth.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1426, 9)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1433, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.toString(); // => '2019-06' +>ym.toString : Symbol(Temporal.PlainYearMonth.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1433, 9)) +>toString : Symbol(Temporal.PlainYearMonth.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); +>calendar : Symbol(calendar, Decl(temporal.ts, 1438, 11)) +>new Intl.DateTimeFormat().resolvedOptions : Symbol(Intl.DateTimeFormat.resolvedOptions, Decl(lib.es5.d.ts, --, --)) +>Intl.DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2025.intl.d.ts, --, --) ... and 1 more) +>DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) +>resolvedOptions : Symbol(Intl.DateTimeFormat.resolvedOptions, Decl(lib.es5.d.ts, --, --)) + + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }); +>ym : Symbol(ym, Decl(temporal.ts, 1439, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>year : Symbol(year, Decl(temporal.ts, 1439, 45)) +>month : Symbol(month, Decl(temporal.ts, 1439, 57)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1439, 67)) + + ym.toLocaleString(); // example output: '6/2019' +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1439, 9)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Same as above, but explicitly specifying the calendar: + ym.toLocaleString(undefined, { calendar }); +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1439, 9)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>undefined : Symbol(undefined) +>calendar : Symbol(calendar, Decl(temporal.ts, 1442, 34)) + + ym.toLocaleString("de-DE", { calendar }); // example output: '6.2019' +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1439, 9)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1444, 32)) + + ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }); // => 'Juni 2019' +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1439, 9)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1445, 32)) +>year : Symbol(year, Decl(temporal.ts, 1445, 47)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1445, 64)) + + ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '6/2019' +>ym.toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1439, 9)) +>toLocaleString : Symbol(Temporal.PlainYearMonth.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1438, 11)) +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Symbol(ym, Decl(temporal.ts, 1450, 9)) +>Temporal.PlainYearMonth.from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainYearMonth : Symbol(Temporal.PlainYearMonth, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainYearMonthConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + ym.toPlainDate({ day: 24 }); // => 2019-06-24 +>ym.toPlainDate : Symbol(Temporal.PlainYearMonth.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>ym : Symbol(ym, Decl(temporal.ts, 1450, 9)) +>toPlainDate : Symbol(Temporal.PlainYearMonth.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 1451, 20)) +} + +{ + let md: Temporal.PlainMonthDay; +>md : Symbol(md, Decl(temporal.ts, 1455, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // Pi day + md = new Temporal.PlainMonthDay(3, 14); // => 03-14 +>md : Symbol(md, Decl(temporal.ts, 1455, 7)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // Leap day + md = new Temporal.PlainMonthDay(2, 29); // => 02-29 +>md : Symbol(md, Decl(temporal.ts, 1455, 7)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let md: Temporal.PlainMonthDay; +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + md = Temporal.PlainMonthDay.from("08-24"); // => 08-24 +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md = Temporal.PlainMonthDay.from("0824"); // => 08-24 +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md = Temporal.PlainMonthDay.from("2006-08-24"); // => 08-24 +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27"); // => 08-24 +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 08-24 + md === Temporal.PlainMonthDay.from(md); // => false +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) + + md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }); // => 08-24 +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>monthCode : Symbol(monthCode, Decl(temporal.ts, 1474, 38)) +>day : Symbol(day, Decl(temporal.ts, 1474, 56)) + + md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // => 08-24 + // (same as above; Temporal.PlainDate has month and day properties) + + // Different overflow modes + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1480, 38)) +>day : Symbol(day, Decl(temporal.ts, 1480, 49)) +>year : Symbol(year, Decl(temporal.ts, 1480, 57)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1480, 73)) + + // => 12-01 + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1482, 38)) +>day : Symbol(day, Decl(temporal.ts, 1482, 48)) +>year : Symbol(year, Decl(temporal.ts, 1482, 57)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1482, 73)) + + // => 01-31 + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1484, 38)) +>day : Symbol(day, Decl(temporal.ts, 1484, 49)) +>year : Symbol(year, Decl(temporal.ts, 1484, 57)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1484, 73)) + + // => throws + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1486, 38)) +>day : Symbol(day, Decl(temporal.ts, 1486, 48)) +>year : Symbol(year, Decl(temporal.ts, 1486, 57)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1486, 73)) + + // => throws + md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1488, 38)) +>day : Symbol(day, Decl(temporal.ts, 1488, 48)) +>year : Symbol(year, Decl(temporal.ts, 1488, 57)) +>overflow : Symbol(overflow, Decl(temporal.ts, 1488, 73)) + + // => throws (this year is not a leap year in the ISO 8601 calendar) + + // non-ISO calendars + md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>monthCode : Symbol(monthCode, Decl(temporal.ts, 1492, 38)) +>day : Symbol(day, Decl(temporal.ts, 1492, 57)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1492, 66)) + + // => 1970-02-21[u-ca=hebrew] + md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1494, 38)) +>day : Symbol(day, Decl(temporal.ts, 1494, 48)) +>year : Symbol(year, Decl(temporal.ts, 1494, 57)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1494, 69)) + + // => 1970-02-21[u-ca=hebrew] + /* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1496, 50)) +>day : Symbol(day, Decl(temporal.ts, 1496, 60)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1496, 69)) + + // => throws (either year or monthCode is required) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.monthCode; // => 'M05L' +>md.monthCode : Symbol(Temporal.PlainMonthDay.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>monthCode : Symbol(Temporal.PlainMonthDay.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.day; // => 15 +>md.day : Symbol(Temporal.PlainMonthDay.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) +>day : Symbol(Temporal.PlainMonthDay.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.month; // undefined +>md : Symbol(md, Decl(temporal.ts, 1464, 7)) + + // (month property is not present in this type; use monthCode instead) +} + +{ + let md: Temporal.PlainMonthDay; +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + md = Temporal.PlainMonthDay.from("08-24"); +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.monthCode; // => 'M08' +>md.monthCode : Symbol(Temporal.PlainMonthDay.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>monthCode : Symbol(Temporal.PlainMonthDay.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.day; // => 24 +>md.day : Symbol(Temporal.PlainMonthDay.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>day : Symbol(Temporal.PlainMonthDay.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.month; // => undefined +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) + + // (no `month` property; use `monthCode` instead) + + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.monthCode; // => 'M05L' +>md.monthCode : Symbol(Temporal.PlainMonthDay.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>monthCode : Symbol(Temporal.PlainMonthDay.monthCode, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.day; // => 15 +>md.day : Symbol(Temporal.PlainMonthDay.day, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) +>day : Symbol(Temporal.PlainMonthDay.day, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.month; // => undefined +>md : Symbol(md, Decl(temporal.ts, 1506, 7)) + + // (no `month` property; use `monthCode` instead) +} + +{ + const md = Temporal.PlainMonthDay.from("11-15"); +>md : Symbol(md, Decl(temporal.ts, 1522, 9)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + // What's the last day of that month? + md.with({ day: 31 }); // => 11-30 +>md.with : Symbol(Temporal.PlainMonthDay.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1522, 9)) +>with : Symbol(Temporal.PlainMonthDay.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 1524, 13)) + + Temporal.PlainMonthDay.from("02-01").with({ day: 31 }); // => 02-29 +>Temporal.PlainMonthDay.from("02-01").with : Symbol(Temporal.PlainMonthDay.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>with : Symbol(Temporal.PlainMonthDay.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>day : Symbol(day, Decl(temporal.ts, 1525, 47)) +} + +{ + const md1 = Temporal.PlainMonthDay.from("02-28"); +>md1 : Symbol(md1, Decl(temporal.ts, 1529, 9)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const md2 = Temporal.PlainMonthDay.from("02-29"); +>md2 : Symbol(md2, Decl(temporal.ts, 1530, 9)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md1.equals(md2); // => false +>md1.equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md1 : Symbol(md1, Decl(temporal.ts, 1529, 9)) +>equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md2 : Symbol(md2, Decl(temporal.ts, 1530, 9)) + + md1.equals("02-29"); // => false +>md1.equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md1 : Symbol(md1, Decl(temporal.ts, 1529, 9)) +>equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) + + md1.equals({ monthCode: "M02", day: 29 }); // => false +>md1.equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md1 : Symbol(md1, Decl(temporal.ts, 1529, 9)) +>equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>monthCode : Symbol(monthCode, Decl(temporal.ts, 1533, 16)) +>day : Symbol(day, Decl(temporal.ts, 1533, 34)) + + md2.equals(md2); // => true +>md2.equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md2 : Symbol(md2, Decl(temporal.ts, 1530, 9)) +>equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md2 : Symbol(md2, Decl(temporal.ts, 1530, 9)) + + md2.equals("02-29"); // => true +>md2.equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md2 : Symbol(md2, Decl(temporal.ts, 1530, 9)) +>equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) + + md2.equals({ monthCode: "M02", day: 29 }); // => true +>md2.equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>md2 : Symbol(md2, Decl(temporal.ts, 1530, 9)) +>equals : Symbol(Temporal.PlainMonthDay.equals, Decl(lib.esnext.temporal.d.ts, --, --)) +>monthCode : Symbol(monthCode, Decl(temporal.ts, 1536, 16)) +>day : Symbol(day, Decl(temporal.ts, 1536, 34)) +} + +{ + const md = Temporal.PlainMonthDay.from("08-24"); +>md : Symbol(md, Decl(temporal.ts, 1540, 9)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + md.toString(); // => '08-24' +>md.toString : Symbol(Temporal.PlainMonthDay.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1540, 9)) +>toString : Symbol(Temporal.PlainMonthDay.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); +>calendar : Symbol(calendar, Decl(temporal.ts, 1545, 11)) +>new Intl.DateTimeFormat().resolvedOptions : Symbol(Intl.DateTimeFormat.resolvedOptions, Decl(lib.es5.d.ts, --, --)) +>Intl.DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.es2025.intl.d.ts, --, --) ... and 1 more) +>DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) +>resolvedOptions : Symbol(Intl.DateTimeFormat.resolvedOptions, Decl(lib.es5.d.ts, --, --)) + + const md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }); +>md : Symbol(md, Decl(temporal.ts, 1546, 9)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>monthCode : Symbol(monthCode, Decl(temporal.ts, 1546, 44)) +>day : Symbol(day, Decl(temporal.ts, 1546, 62)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1546, 71)) + + md.toLocaleString(); // example output: '8/24' +>md.toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1546, 9)) +>toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Same as above, but explicitly specifying the calendar: + md.toLocaleString(undefined, { calendar }); // example output: '8/24' +>md.toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1546, 9)) +>toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>undefined : Symbol(undefined) +>calendar : Symbol(calendar, Decl(temporal.ts, 1549, 34)) + + md.toLocaleString("de-DE", { calendar }); // => '24.8.' +>md.toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1546, 9)) +>toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1551, 32)) + + md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }); // => '24. August' +>md.toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1546, 9)) +>toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>month : Symbol(month, Decl(temporal.ts, 1552, 32)) +>day : Symbol(day, Decl(temporal.ts, 1552, 47)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1552, 63)) + + md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '8/24' +>md.toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1546, 9)) +>toLocaleString : Symbol(Temporal.PlainMonthDay.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>calendar : Symbol(calendar, Decl(temporal.ts, 1545, 11)) +} + +{ + const md = Temporal.PlainMonthDay.from({ +>md : Symbol(md, Decl(temporal.ts, 1557, 9)) +>Temporal.PlainMonthDay.from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainMonthDay : Symbol(Temporal.PlainMonthDay, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainMonthDayConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + calendar: "japanese", +>calendar : Symbol(calendar, Decl(temporal.ts, 1557, 44)) + + monthCode: "M01", +>monthCode : Symbol(monthCode, Decl(temporal.ts, 1558, 29)) + + day: 1, +>day : Symbol(day, Decl(temporal.ts, 1559, 25)) + + }); + + const date = md.toPlainDate({ era: "reiwa", eraYear: 2 }); // => 2020-01-01[u-ca=japanese] +>date : Symbol(date, Decl(temporal.ts, 1563, 9)) +>md.toPlainDate : Symbol(Temporal.PlainMonthDay.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>md : Symbol(md, Decl(temporal.ts, 1557, 9)) +>toPlainDate : Symbol(Temporal.PlainMonthDay.toPlainDate, Decl(lib.esnext.temporal.d.ts, --, --)) +>era : Symbol(era, Decl(temporal.ts, 1563, 33)) +>eraYear : Symbol(eraYear, Decl(temporal.ts, 1563, 47)) +} + +{ + new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); // => P1Y2M3W4DT5H6M7.987654321S +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + new Temporal.Duration(0, 0, 0, 40); // => P40D +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + new Temporal.Duration(undefined, undefined, undefined, 40); // => P40D +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + + new Temporal.Duration(); // => PT0S +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let d: Temporal.Duration; +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from({ years: 1, days: 1 }); // => P1Y1D +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1576, 32)) +>days : Symbol(days, Decl(temporal.ts, 1576, 42)) + + d = Temporal.Duration.from({ days: -2, hours: -12 }); // => -P2DT12H +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1577, 32)) +>hours : Symbol(hours, Decl(temporal.ts, 1577, 42)) + + Temporal.Duration.from(d) === d; // => false +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) + + d = Temporal.Duration.from("P1Y1D"); // => P1Y1D +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from("-P2DT12H"); // => -P2DT12H +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from("P0D"); // => PT0S +>d : Symbol(d, Decl(temporal.ts, 1574, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const one = Temporal.Duration.from({ hours: 79, minutes: 10 }); +>one : Symbol(one, Decl(temporal.ts, 1587, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1587, 40)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1587, 51)) + + const two = Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }); +>two : Symbol(two, Decl(temporal.ts, 1588, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1588, 40)) +>hours : Symbol(hours, Decl(temporal.ts, 1588, 49)) +>seconds : Symbol(seconds, Decl(temporal.ts, 1588, 59)) + + const three = Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }); +>three : Symbol(three, Decl(temporal.ts, 1589, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1589, 42)) +>hours : Symbol(hours, Decl(temporal.ts, 1589, 51)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1589, 61)) + + const sorted1 = [one, two, three].sort(Temporal.Duration.compare); +>sorted1 : Symbol(sorted1, Decl(temporal.ts, 1590, 9)) +>[one, two, three].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1587, 9)) +>two : Symbol(two, Decl(temporal.ts, 1588, 9)) +>three : Symbol(three, Decl(temporal.ts, 1589, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>Temporal.Duration.compare : Symbol(Temporal.DurationConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.DurationConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) + + sorted1.join(" "); +>sorted1.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted1 : Symbol(sorted1, Decl(temporal.ts, 1590, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) + + // => 'P3DT6H50M PT79H10M P3DT7H630S' + + // Sorting relative to a date, taking DST changes into account: + const relativeTo = Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]"); +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1595, 9)) +>Temporal.ZonedDateTime.from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>ZonedDateTime : Symbol(Temporal.ZonedDateTime, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.ZonedDateTimeConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + const sorted2 = [one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })); +>sorted2 : Symbol(sorted2, Decl(temporal.ts, 1596, 9)) +>[one, two, three].sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1587, 9)) +>two : Symbol(two, Decl(temporal.ts, 1588, 9)) +>three : Symbol(three, Decl(temporal.ts, 1589, 9)) +>sort : Symbol(Array.sort, Decl(lib.es5.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1596, 44)) +>two : Symbol(two, Decl(temporal.ts, 1596, 48)) +>Temporal.Duration.compare : Symbol(Temporal.DurationConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>compare : Symbol(Temporal.DurationConstructor.compare, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1596, 44)) +>two : Symbol(two, Decl(temporal.ts, 1596, 48)) +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1596, 94)) + + sorted2.join(" "); +>sorted2.join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) +>sorted2 : Symbol(sorted2, Decl(temporal.ts, 1596, 9)) +>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --)) + + // => 'PT79H10M P3DT6H50M P3DT7H630S' +} + +{ + const d = Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S"); +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.years; // => 1 +>d.years : Symbol(Temporal.Duration.years, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>years : Symbol(Temporal.Duration.years, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.months; // => 2 +>d.months : Symbol(Temporal.Duration.months, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>months : Symbol(Temporal.Duration.months, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.weeks; // => 3 +>d.weeks : Symbol(Temporal.Duration.weeks, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>weeks : Symbol(Temporal.Duration.weeks, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.days; // => 4 +>d.days : Symbol(Temporal.Duration.days, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>days : Symbol(Temporal.Duration.days, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.hours; // => 5 +>d.hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>hours : Symbol(Temporal.Duration.hours, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.minutes; // => 6 +>d.minutes : Symbol(Temporal.Duration.minutes, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>minutes : Symbol(Temporal.Duration.minutes, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.seconds; // => 7 +>d.seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.milliseconds; // => 987 +>d.milliseconds : Symbol(Temporal.Duration.milliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>milliseconds : Symbol(Temporal.Duration.milliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.microseconds; // => 654 +>d.microseconds : Symbol(Temporal.Duration.microseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>microseconds : Symbol(Temporal.Duration.microseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.nanoseconds; // => 321 +>d.nanoseconds : Symbol(Temporal.Duration.nanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1602, 9)) +>nanoseconds : Symbol(Temporal.Duration.nanoseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let d: Temporal.Duration; +>d : Symbol(d, Decl(temporal.ts, 1616, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from("PT0S"); +>d : Symbol(d, Decl(temporal.ts, 1616, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.blank; // => true +>d.blank : Symbol(Temporal.Duration.blank, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1616, 7)) +>blank : Symbol(Temporal.Duration.blank, Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }); +>d : Symbol(d, Decl(temporal.ts, 1616, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1621, 32)) +>hours : Symbol(hours, Decl(temporal.ts, 1621, 41)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1621, 51)) + + d.blank; // => true +>d.blank : Symbol(Temporal.Duration.blank, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1616, 7)) +>blank : Symbol(Temporal.Duration.blank, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let duration: Temporal.Duration; +>duration : Symbol(duration, Decl(temporal.ts, 1626, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }); +>duration : Symbol(duration, Decl(temporal.ts, 1626, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1628, 39)) +>days : Symbol(days, Decl(temporal.ts, 1628, 51)) +>hours : Symbol(hours, Decl(temporal.ts, 1628, 61)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1628, 72)) + + // Perform a balance operation using additional ISO 8601 calendar rules: + let { years, months } = duration; +>years : Symbol(years, Decl(temporal.ts, 1630, 9)) +>months : Symbol(months, Decl(temporal.ts, 1630, 16)) +>duration : Symbol(duration, Decl(temporal.ts, 1626, 7)) + + years += Math.floor(months / 12); +>years : Symbol(years, Decl(temporal.ts, 1630, 9)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1630, 16)) + + months %= 12; +>months : Symbol(months, Decl(temporal.ts, 1630, 16)) + + duration = duration.with({ years, months }); +>duration : Symbol(duration, Decl(temporal.ts, 1626, 7)) +>duration.with : Symbol(Temporal.Duration.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>duration : Symbol(duration, Decl(temporal.ts, 1626, 7)) +>with : Symbol(Temporal.Duration.with, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1633, 30)) +>months : Symbol(months, Decl(temporal.ts, 1633, 37)) + + // => P4Y2M50DT50H100M +} + +{ + const hour = Temporal.Duration.from("PT1H"); +>hour : Symbol(hour, Decl(temporal.ts, 1638, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + hour.add({ minutes: 30 }); // => PT1H30M +>hour.add : Symbol(Temporal.Duration.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>hour : Symbol(hour, Decl(temporal.ts, 1638, 9)) +>add : Symbol(Temporal.Duration.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1639, 14)) + + // Examples of balancing: + const one = Temporal.Duration.from({ hours: 1, minutes: 30 }); +>one : Symbol(one, Decl(temporal.ts, 1642, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1642, 40)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1642, 50)) + + const two = Temporal.Duration.from({ hours: 2, minutes: 45 }); +>two : Symbol(two, Decl(temporal.ts, 1643, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1643, 40)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1643, 50)) + + const result = one.add(two); // => PT4H15M +>result : Symbol(result, Decl(temporal.ts, 1644, 9)) +>one.add : Symbol(Temporal.Duration.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1642, 9)) +>add : Symbol(Temporal.Duration.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>two : Symbol(two, Decl(temporal.ts, 1643, 9)) + + // Example of adding calendar units + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 16 }); +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1647, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1647, 53)) +>days : Symbol(days, Decl(temporal.ts, 1647, 64)) + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2000-12-01"); +>startDate1 : Symbol(startDate1, Decl(temporal.ts, 1650, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) +>startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) .since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1.add(oneAndAHalfMonth).add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1 : Symbol(startDate1, Decl(temporal.ts, 1650, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1647, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1647, 9)) + + .since(startDate1, { largestUnit: "months" }); // => P3M4D +>since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1 : Symbol(startDate1, Decl(temporal.ts, 1650, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1652, 28)) + + const startDate2 = Temporal.PlainDate.from("2001-01-01"); +>startDate2 : Symbol(startDate2, Decl(temporal.ts, 1654, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) +>startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) .since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2.add(oneAndAHalfMonth).add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2 : Symbol(startDate2, Decl(temporal.ts, 1654, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1647, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1647, 9)) + + .since(startDate2, { largestUnit: "months" }); // => P3M1D +>since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2 : Symbol(startDate2, Decl(temporal.ts, 1654, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1656, 28)) +} + +{ + const hourAndAHalf = Temporal.Duration.from("PT1H30M"); +>hourAndAHalf : Symbol(hourAndAHalf, Decl(temporal.ts, 1660, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + hourAndAHalf.subtract({ hours: 1 }); // => PT30M +>hourAndAHalf.subtract : Symbol(Temporal.Duration.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>hourAndAHalf : Symbol(hourAndAHalf, Decl(temporal.ts, 1660, 9)) +>subtract : Symbol(Temporal.Duration.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1661, 27)) + + const one = Temporal.Duration.from({ minutes: 180 }); +>one : Symbol(one, Decl(temporal.ts, 1663, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1663, 40)) + + const two = Temporal.Duration.from({ seconds: 30 }); +>two : Symbol(two, Decl(temporal.ts, 1664, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>seconds : Symbol(seconds, Decl(temporal.ts, 1664, 40)) + + one.subtract(two); // => PT179M30S +>one.subtract : Symbol(Temporal.Duration.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1663, 9)) +>subtract : Symbol(Temporal.Duration.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>two : Symbol(two, Decl(temporal.ts, 1664, 9)) + + one.subtract(two).round({ largestUnit: "hour" }); // => PT2H59M30S +>one.subtract(two).round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>one.subtract : Symbol(Temporal.Duration.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>one : Symbol(one, Decl(temporal.ts, 1663, 9)) +>subtract : Symbol(Temporal.Duration.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>two : Symbol(two, Decl(temporal.ts, 1664, 9)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1666, 29)) + + // Example of subtracting calendar units; cannot be subtracted using + // subtract() because units need to be converted + const threeMonths = Temporal.Duration.from({ months: 3 }); +>threeMonths : Symbol(threeMonths, Decl(temporal.ts, 1670, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1670, 48)) + + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 15 }); +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1671, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1671, 53)) +>days : Symbol(days, Decl(temporal.ts, 1671, 64)) + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2001-01-01"); +>startDate1 : Symbol(startDate1, Decl(temporal.ts, 1674, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + startDate1.add(threeMonths).subtract(oneAndAHalfMonth) +>startDate1.add(threeMonths).subtract(oneAndAHalfMonth) .since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1.add(threeMonths).subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1 : Symbol(startDate1, Decl(temporal.ts, 1674, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>threeMonths : Symbol(threeMonths, Decl(temporal.ts, 1670, 9)) +>subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1671, 9)) + + .since(startDate1, { largestUnit: "months" }); // => P1M13D +>since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate1 : Symbol(startDate1, Decl(temporal.ts, 1674, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1676, 28)) + + const startDate2 = Temporal.PlainDate.from("2001-02-01"); +>startDate2 : Symbol(startDate2, Decl(temporal.ts, 1678, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + startDate2.add(threeMonths).subtract(oneAndAHalfMonth) +>startDate2.add(threeMonths).subtract(oneAndAHalfMonth) .since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2.add(threeMonths).subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2.add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2 : Symbol(startDate2, Decl(temporal.ts, 1678, 9)) +>add : Symbol(Temporal.PlainDate.add, Decl(lib.esnext.temporal.d.ts, --, --)) +>threeMonths : Symbol(threeMonths, Decl(temporal.ts, 1670, 9)) +>subtract : Symbol(Temporal.PlainDate.subtract, Decl(lib.esnext.temporal.d.ts, --, --)) +>oneAndAHalfMonth : Symbol(oneAndAHalfMonth, Decl(temporal.ts, 1671, 9)) + + .since(startDate2, { largestUnit: "months" }); // => P1M16D +>since : Symbol(Temporal.PlainDate.since, Decl(lib.esnext.temporal.d.ts, --, --)) +>startDate2 : Symbol(startDate2, Decl(temporal.ts, 1678, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1680, 28)) +} + +{ + const d = Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S"); +>d : Symbol(d, Decl(temporal.ts, 1684, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.sign; // 1 +>d.sign : Symbol(Temporal.Duration.sign, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1684, 9)) +>sign : Symbol(Temporal.Duration.sign, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.negated(); // -P1Y2M3DT4H5M6.987654321S +>d.negated : Symbol(Temporal.Duration.negated, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1684, 9)) +>negated : Symbol(Temporal.Duration.negated, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.negated().sign; // -1 +>d.negated().sign : Symbol(Temporal.Duration.sign, Decl(lib.esnext.temporal.d.ts, --, --)) +>d.negated : Symbol(Temporal.Duration.negated, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1684, 9)) +>negated : Symbol(Temporal.Duration.negated, Decl(lib.esnext.temporal.d.ts, --, --)) +>sign : Symbol(Temporal.Duration.sign, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + const d = Temporal.Duration.from("-PT8H30M"); +>d : Symbol(d, Decl(temporal.ts, 1691, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.abs(); // PT8H30M +>d.abs : Symbol(Temporal.Duration.abs, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1691, 9)) +>abs : Symbol(Temporal.Duration.abs, Decl(lib.esnext.temporal.d.ts, --, --)) +} + +{ + let d: Temporal.Duration; +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // Balance a duration as far as possible without knowing a starting point + d = Temporal.Duration.from({ minutes: 130 }); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1699, 32)) + + d.round({ largestUnit: "day" }); // => PT2H10M +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1700, 13)) + + // Round to the nearest unit + d = Temporal.Duration.from({ minutes: 10, seconds: 52 }); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1703, 32)) +>seconds : Symbol(seconds, Decl(temporal.ts, 1703, 45)) + + d.round({ smallestUnit: "minute" }); // => PT11M +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1704, 13)) + + d.round({ smallestUnit: "minute", roundingMode: "trunc" }); // => PT10M +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1705, 13)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 1705, 37)) + + // How many seconds in a multi-unit duration? + d = Temporal.Duration.from("PT2H34M18S"); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.round({ largestUnit: "second" }).seconds; // => 9258 +>d.round({ largestUnit: "second" }).seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1709, 13)) +>seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + // Normalize, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1712, 32)) + + d.round({ +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1713, 13)) + + largestUnit: "year", +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1714, 58)) + + }); // => P114DT21H + // (one hour longer because DST skipped an hour) + d.round({ +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + relativeTo: "2020-01-01", +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1718, 13)) + + largestUnit: "year", +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1719, 33)) + + }); // => P114DT20H + // (one hour shorter if ignoring DST) + + // Normalize days into months or years + d = Temporal.Duration.from({ days: 190 }); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1725, 32)) + + const refDate = Temporal.PlainDate.from("2020-01-01"); +>refDate : Symbol(refDate, Decl(temporal.ts, 1726, 9)) +>Temporal.PlainDate.from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>PlainDate : Symbol(Temporal.PlainDate, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.PlainDateConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.round({ relativeTo: refDate, largestUnit: "year" }); // => P6M8D +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1727, 13)) +>refDate : Symbol(refDate, Decl(temporal.ts, 1726, 9)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1727, 34)) + + // Same, but in a different calendar system + d.round({ +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + relativeTo: refDate.withCalendar("hebrew"), +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1730, 13)) +>refDate.withCalendar : Symbol(Temporal.PlainDate.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) +>refDate : Symbol(refDate, Decl(temporal.ts, 1726, 9)) +>withCalendar : Symbol(Temporal.PlainDate.withCalendar, Decl(lib.esnext.temporal.d.ts, --, --)) + + largestUnit: "year", +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1731, 51)) + + }); // => P6M13D + + // Round a duration up to the next 5-minute billing period + d = Temporal.Duration.from({ minutes: 6 }); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1736, 32)) + + d.round({ +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + smallestUnit: "minute", +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1737, 13)) + + roundingIncrement: 5, +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 1738, 31)) + + roundingMode: "ceil", +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 1739, 29)) + + }); // => PT10M + + // How many full 3-month quarters of this year, are in this duration? + d = Temporal.Duration.from({ months: 10, days: 15 }); +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>months : Symbol(months, Decl(temporal.ts, 1744, 32)) +>days : Symbol(days, Decl(temporal.ts, 1744, 44)) + + d = d.round({ +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>d.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + smallestUnit: "month", +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1745, 17)) + + roundingIncrement: 3, +>roundingIncrement : Symbol(roundingIncrement, Decl(temporal.ts, 1746, 30)) + + roundingMode: "trunc", +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 1747, 29)) + + relativeTo: Temporal.Now.plainDateISO(), +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1748, 30)) +>Temporal.Now.plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + }); + const quarters = d.months / 3; +>quarters : Symbol(quarters, Decl(temporal.ts, 1751, 9)) +>d.months : Symbol(Temporal.Duration.months, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1696, 7)) +>months : Symbol(Temporal.Duration.months, Decl(lib.esnext.temporal.d.ts, --, --)) + + quarters; // => 3 +>quarters : Symbol(quarters, Decl(temporal.ts, 1751, 9)) +} + +{ + let d: Temporal.Duration; +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + // How many seconds in 130 hours and 20 minutes? + d = Temporal.Duration.from({ hours: 130, minutes: 20 }); +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1759, 32)) +>minutes : Symbol(minutes, Decl(temporal.ts, 1759, 44)) + + d.total({ unit: "second" }); // => 469200 +>d.total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>unit : Symbol(unit, Decl(temporal.ts, 1760, 13)) + + // How many 24-hour days is 123456789 seconds? + d = Temporal.Duration.from("PT123456789S"); +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.total({ unit: "day" }); // 1428.8980208333332 +>d.total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>unit : Symbol(unit, Decl(temporal.ts, 1764, 13)) + + // Find totals in months, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>hours : Symbol(hours, Decl(temporal.ts, 1767, 32)) + + d.total({ +>d.total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1768, 13)) + + unit: "month", +>unit : Symbol(unit, Decl(temporal.ts, 1769, 58)) + + }); // => 3.7958333333333334 + d.total({ +>d.total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1756, 7)) +>total : Symbol(Temporal.Duration.total, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + unit: "month", +>unit : Symbol(unit, Decl(temporal.ts, 1772, 13)) + + relativeTo: "2020-01-01", +>relativeTo : Symbol(relativeTo, Decl(temporal.ts, 1773, 22)) + + }); // => 3.7944444444444443 +} + +{ + let d: Temporal.Duration; +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from({ years: 1, days: 1 }); +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1781, 32)) +>days : Symbol(days, Decl(temporal.ts, 1781, 42)) + + d.toString(); // => P1Y1D +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from({ years: -1, days: -1 }); +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>years : Symbol(years, Decl(temporal.ts, 1783, 32)) +>days : Symbol(days, Decl(temporal.ts, 1783, 43)) + + d.toString(); // => -P1Y1D +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from({ milliseconds: 1000 }); +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>milliseconds : Symbol(milliseconds, Decl(temporal.ts, 1785, 32)) + + d.toString(); // => PT1S +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) + + // The output format always balances units under 1 s, even if the + // underlying Temporal.Duration object doesn't. + const nobal = Temporal.Duration.from({ milliseconds: 3500 }); +>nobal : Symbol(nobal, Decl(temporal.ts, 1790, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>milliseconds : Symbol(milliseconds, Decl(temporal.ts, 1790, 42)) + + console.log(`${nobal}`, nobal.seconds, nobal.milliseconds); // => 'PT3.5S 0 3500' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>nobal : Symbol(nobal, Decl(temporal.ts, 1790, 9)) +>nobal.seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>nobal : Symbol(nobal, Decl(temporal.ts, 1790, 9)) +>seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>nobal.milliseconds : Symbol(Temporal.Duration.milliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>nobal : Symbol(nobal, Decl(temporal.ts, 1790, 9)) +>milliseconds : Symbol(Temporal.Duration.milliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + const bal = nobal.round({ largestUnit: "year" }); // balance through round +>bal : Symbol(bal, Decl(temporal.ts, 1792, 9)) +>nobal.round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>nobal : Symbol(nobal, Decl(temporal.ts, 1790, 9)) +>round : Symbol(Temporal.Duration.round, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>largestUnit : Symbol(largestUnit, Decl(temporal.ts, 1792, 29)) + + console.log(`${bal}`, bal.seconds, bal.milliseconds); // => 'PT3.5S 3 500' +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>bal : Symbol(bal, Decl(temporal.ts, 1792, 9)) +>bal.seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>bal : Symbol(bal, Decl(temporal.ts, 1792, 9)) +>seconds : Symbol(Temporal.Duration.seconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>bal.milliseconds : Symbol(Temporal.Duration.milliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) +>bal : Symbol(bal, Decl(temporal.ts, 1792, 9)) +>milliseconds : Symbol(Temporal.Duration.milliseconds, Decl(lib.esnext.temporal.d.ts, --, --)) + + d = Temporal.Duration.from("PT59.999999999S"); +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.toString({ smallestUnit: "second" }); // => PT59S +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>smallestUnit : Symbol(smallestUnit, Decl(temporal.ts, 1796, 16)) + + d.toString({ fractionalSecondDigits: 0 }); // => PT59S +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 1797, 16)) + + d.toString({ fractionalSecondDigits: 4 }); // => PT59.9999S +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 1798, 16)) + + d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); +>d.toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1779, 7)) +>toString : Symbol(Temporal.Duration.toString, Decl(lib.esnext.temporal.d.ts, --, --)) +>fractionalSecondDigits : Symbol(fractionalSecondDigits, Decl(temporal.ts, 1799, 16)) +>roundingMode : Symbol(roundingMode, Decl(temporal.ts, 1799, 43)) + + // => PT60.00000000S +} + +{ + const d = Temporal.Duration.from("P1DT6H30M"); +>d : Symbol(d, Decl(temporal.ts, 1804, 9)) +>Temporal.Duration.from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Duration : Symbol(Temporal.Duration, Decl(lib.esnext.temporal.d.ts, --, --), Decl(lib.esnext.temporal.d.ts, --, --)) +>from : Symbol(Temporal.DurationConstructor.from, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.toLocaleString(); // example output: '1 day 6 hours 30 minutes' +>d.toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1804, 9)) +>toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.toLocaleString("de-DE"); // example output: '1 Tag 6 Stunden 30 Minuten' +>d.toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1804, 9)) +>toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) + + d.toLocaleString("en-US", { days: "short", hours: "numeric" }); // example output: '1 day 6 hours' +>d.toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>d : Symbol(d, Decl(temporal.ts, 1804, 9)) +>toLocaleString : Symbol(Temporal.Duration.toLocaleString, Decl(lib.esnext.temporal.d.ts, --, --)) +>days : Symbol(days, Decl(temporal.ts, 1807, 31)) +>hours : Symbol(hours, Decl(temporal.ts, 1807, 46)) +} + +{ + Temporal.Now.instant(); // get the current system exact time +>Temporal.Now.instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>instant : Symbol(Temporal.Now.instant, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.Now.timeZoneId(); // get the current system time zone +>Temporal.Now.timeZoneId : Symbol(Temporal.Now.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>timeZoneId : Symbol(Temporal.Now.timeZoneId, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.Now.zonedDateTimeISO(); // get the current date and wall-clock time in the system time zone and ISO-8601 calendar +>Temporal.Now.zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>zonedDateTimeISO : Symbol(Temporal.Now.zonedDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.Now.plainDateISO(); // get the current date in the system time zone and ISO-8601 calendar +>Temporal.Now.plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateISO : Symbol(Temporal.Now.plainDateISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.Now.plainTimeISO(); // get the current wall-clock time in the system time zone and ISO-8601 calendar +>Temporal.Now.plainTimeISO : Symbol(Temporal.Now.plainTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainTimeISO : Symbol(Temporal.Now.plainTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) + + Temporal.Now.plainDateTimeISO(); // same as above, but return the DateTime in the ISO-8601 calendar +>Temporal.Now.plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal.Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>Temporal : Symbol(Temporal, Decl(lib.esnext.temporal.d.ts, --, --)) +>Now : Symbol(Temporal.Now, Decl(lib.esnext.temporal.d.ts, --, --)) +>plainDateTimeISO : Symbol(Temporal.Now.plainDateTimeISO, Decl(lib.esnext.temporal.d.ts, --, --)) +} + diff --git a/tests/baselines/reference/temporal.types b/tests/baselines/reference/temporal.types new file mode 100644 index 0000000000000..db094a61dc0e3 --- /dev/null +++ b/tests/baselines/reference/temporal.types @@ -0,0 +1,15687 @@ +//// [tests/cases/compiler/temporal.ts] //// + +=== Performance Stats === +Type Count: 2,500 + +=== temporal.ts === +/** + * Test cases derived from documentation at tc39/proposal-temporal, + * under the following license: + * + * Copyright 2017, 2018, 2019, 2020 ECMA International + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +{ + const instant = Temporal.Instant.from("2020-01-01T00:00+05:30"); // => 2019-12-31T18:30:00Z +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2020-01-01T00:00+05:30") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-01T00:00+05:30" : "2020-01-01T00:00+05:30" +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + instant.epochNanoseconds; // => 1577817000000000000n +>instant.epochNanoseconds : bigint +> : ^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>epochNanoseconds : bigint +> : ^^^^^^ + + // `Temporal.Instant` lacks properties that depend on time zone or calendar + instant.year; // => undefined +>instant.year : any +> : ^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>year : any +> : ^^^ + + const zdtTokyo = instant.toZonedDateTimeISO("Asia/Tokyo"); // => 2020-01-01T03:30:00+09:00[Asia/Tokyo] +>zdtTokyo : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>instant.toZonedDateTimeISO("Asia/Tokyo") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>instant.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Tokyo" : "Asia/Tokyo" +> : ^^^^^^^^^^^^ + + zdtTokyo.year; // => 2020 +>zdtTokyo.year : number +> : ^^^^^^ +>zdtTokyo : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + zdtTokyo.toPlainDate(); // => 2020-01-01 +>zdtTokyo.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>zdtTokyo.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>zdtTokyo : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + // Convert from `Temporal.Instant` to `Date` (which uses millisecond precision) + const instant = Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30"); +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-01T00:00:00.123456789+05:30" : "2020-01-01T00:00:00.123456789+05:30" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 2019-12-31T18:30:00.123456789Z + const date = new Date(instant.epochMilliseconds); +>date : Date +> : ^^^^ +>new Date(instant.epochMilliseconds) : Date +> : ^^^^ +>Date : DateConstructor +> : ^^^^^^^^^^^^^^^ +>instant.epochMilliseconds : number +> : ^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>epochMilliseconds : number +> : ^^^^^^ + + date.toISOString(); // => 2019-12-31T18:30:00.123Z +>date.toISOString() : string +> : ^^^^^^ +>date.toISOString : () => string +> : ^^^^^^ +>date : Date +> : ^^^^ +>toISOString : () => string +> : ^^^^^^ + + // Convert from `Date` to `Temporal.Instant` + const sameInstant = date.toTemporalInstant(); // => 2019-12-31T18:30:00.123Z +>sameInstant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>date.toTemporalInstant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>date.toTemporalInstant : () => Temporal.Instant +> : ^^^^^^ +>date : Date +> : ^^^^ +>toTemporalInstant : () => Temporal.Instant +> : ^^^^^^ +} + +{ + const date = new Date(2019, 11, 31, 18, 30); // => Tue Dec 31 2019 18:30:00 GMT-0800 (Pacific Standard Time) +>date : Date +> : ^^^^ +>new Date(2019, 11, 31, 18, 30) : Date +> : ^^^^ +>Date : DateConstructor +> : ^^^^^^^^^^^^^^^ +>2019 : 2019 +> : ^^^^ +>11 : 11 +> : ^^ +>31 : 31 +> : ^^ +>18 : 18 +> : ^^ +>30 : 30 +> : ^^ + + const instant = date.toTemporalInstant(); // => 2020-01-01T02:30:00Z +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>date.toTemporalInstant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>date.toTemporalInstant : () => Temporal.Instant +> : ^^^^^^ +>date : Date +> : ^^^^ +>toTemporalInstant : () => Temporal.Instant +> : ^^^^^^ + + const zonedDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()); +>zonedDateTime : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>instant.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.timeZoneId() : string +> : ^^^^^^ +>Temporal.Now.timeZoneId : () => string +> : ^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>timeZoneId : () => string +> : ^^^^^^ + + // => 2019-12-31T18:30:00-08:00[America/Los_Angeles] + zonedDateTime.day; // => 31 +>zonedDateTime.day : number +> : ^^^^^^ +>zonedDateTime : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + const dateOnly = zonedDateTime.toPlainDate(); // => 2019-12-31 +>dateOnly : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>zonedDateTime.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>zonedDateTime.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>zonedDateTime : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const instant = new Temporal.Instant(1553906700000000000n); +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>new Temporal.Instant(1553906700000000000n) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>1553906700000000000n : 1553906700000000000n +> : ^^^^^^^^^^^^^^^^^^^^ + + // When was the Unix epoch? + const epoch = new Temporal.Instant(0n); // => 1970-01-01T00:00:00Z +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>new Temporal.Instant(0n) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>0n : 0n +> : ^^ + + // Dates before the Unix epoch are negative + const turnOfTheCentury = new Temporal.Instant(-2208988800000000000n); // => 1900-01-01T00:00:00Z +>turnOfTheCentury : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>new Temporal.Instant(-2208988800000000000n) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>-2208988800000000000n : -2208988800000000000n +> : ^^^^^^^^^^^^^^^^^^^^^ +>2208988800000000000n : 2208988800000000000n +> : ^^^^^^^^^^^^^^^^^^^^ +} + +{ + let instant: Temporal.Instant; +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]"); +>instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-30T01:45:00+01:00[Europe/Berlin]" : "2019-03-30T01:45:00+01:00[Europe/Berlin]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + instant = Temporal.Instant.from("2019-03-30T01:45+01:00"); +>instant = Temporal.Instant.from("2019-03-30T01:45+01:00") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2019-03-30T01:45+01:00") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-30T01:45+01:00" : "2019-03-30T01:45+01:00" +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + instant = Temporal.Instant.from("2019-03-30T00:45Z"); +>instant = Temporal.Instant.from("2019-03-30T00:45Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2019-03-30T00:45Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-30T00:45Z" : "2019-03-30T00:45Z" +> : ^^^^^^^^^^^^^^^^^^^ + + instant === Temporal.Instant.from(instant); // => false +>instant === Temporal.Instant.from(instant) : boolean +> : ^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from(instant) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +} + +{ + const legacyDate = new Date("1995-12-17T03:24Z"); +>legacyDate : Date +> : ^^^^ +>new Date("1995-12-17T03:24Z") : Date +> : ^^^^ +>Date : DateConstructor +> : ^^^^^^^^^^^^^^^ +>"1995-12-17T03:24Z" : "1995-12-17T03:24Z" +> : ^^^^^^^^^^^^^^^^^^^ + + let instant: Temporal.Instant; +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()); // => 1995-12-17T03:24:00Z +>instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>legacyDate.getTime() : number +> : ^^^^^^ +>legacyDate.getTime : () => number +> : ^^^^^^ +>legacyDate : Date +> : ^^^^ +>getTime : () => number +> : ^^^^^^ + + instant = legacyDate.toTemporalInstant(); // recommended +>instant = legacyDate.toTemporalInstant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>legacyDate.toTemporalInstant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>legacyDate.toTemporalInstant : () => Temporal.Instant +> : ^^^^^^ +>legacyDate : Date +> : ^^^^ +>toTemporalInstant : () => Temporal.Instant +> : ^^^^^^ +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); +>one : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1.0e12) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1.0e12 : 1000000000000 +> : ^^^^^^^^^^^^^ + + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); +>two : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1.1e12) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1.1e12 : 1100000000000 +> : ^^^^^^^^^^^^^ + + const three = Temporal.Instant.fromEpochMilliseconds(1.2e12); +>three : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1.2e12) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1.2e12 : 1200000000000 +> : ^^^^^^^^^^^^^ + + const sorted = [three, one, two].sort(Temporal.Instant.compare); +>sorted : Temporal.Instant[] +> : ^^^^^^^^^^^^^^^^^^ +>[three, one, two].sort(Temporal.Instant.compare) : Temporal.Instant[] +> : ^^^^^^^^^^^^^^^^^^ +>[three, one, two].sort : (compareFn?: ((a: Temporal.Instant, b: Temporal.Instant) => number) | undefined) => Temporal.Instant[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[three, one, two] : Temporal.Instant[] +> : ^^^^^^^^^^^^^^^^^^ +>three : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>one : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>two : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.Instant, b: Temporal.Instant) => number) | undefined) => Temporal.Instant[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant.compare : (one: Temporal.InstantLike, two: Temporal.InstantLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.InstantLike, two: Temporal.InstantLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + sorted.join(" "); +>sorted.join(" ") : string +> : ^^^^^^ +>sorted.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted : Temporal.Instant[] +> : ^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ + + // => '2001-09-09T01:46:40Z 2004-11-09T11:33:20Z 2008-01-10T21:20:00Z' +} + +{ + const instant = Temporal.Instant.from("2019-03-30T00:45Z"); +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2019-03-30T00:45Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-30T00:45Z" : "2019-03-30T00:45Z" +> : ^^^^^^^^^^^^^^^^^^^ + + new Date(instant.epochMilliseconds); // => 2019-03-30T00:45:00.000Z +>new Date(instant.epochMilliseconds) : Date +> : ^^^^ +>Date : DateConstructor +> : ^^^^^^^^^^^^^^^ +>instant.epochMilliseconds : number +> : ^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>epochMilliseconds : number +> : ^^^^^^ + + // If you need epoch seconds data: + const epochSecs = Math.floor(instant.epochMilliseconds / 1000); // => 1553906700 +>epochSecs : number +> : ^^^^^^ +>Math.floor(instant.epochMilliseconds / 1000) : number +> : ^^^^^^ +>Math.floor : (x: number) => number +> : ^ ^^ ^^^^^ +>Math : Math +> : ^^^^ +>floor : (x: number) => number +> : ^ ^^ ^^^^^ +>instant.epochMilliseconds / 1000 : number +> : ^^^^^^ +>instant.epochMilliseconds : number +> : ^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>epochMilliseconds : number +> : ^^^^^^ +>1000 : 1000 +> : ^^^^ + + const ns = instant.epochNanoseconds; +>ns : bigint +> : ^^^^^^ +>instant.epochNanoseconds : bigint +> : ^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>epochNanoseconds : bigint +> : ^^^^^^ + + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +>epochMicros : bigint +> : ^^^^^^ +>ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n) : bigint +> : ^^^^^^ +>ns / 1000n : bigint +> : ^^^^^^ +>ns : bigint +> : ^^^^^^ +>1000n : 1000n +> : ^^^^^ +>((ns % 1000n) < 0n ? -1n : 0n) : 0n | -1n +> : ^^^^^^^^ +>(ns % 1000n) < 0n ? -1n : 0n : 0n | -1n +> : ^^^^^^^^ +>(ns % 1000n) < 0n : boolean +> : ^^^^^^^ +>(ns % 1000n) : bigint +> : ^^^^^^ +>ns % 1000n : bigint +> : ^^^^^^ +>ns : bigint +> : ^^^^^^ +>1000n : 1000n +> : ^^^^^ +>0n : 0n +> : ^^ +>-1n : -1n +> : ^^^ +>1n : 1n +> : ^^ +>0n : 0n +> : ^^ +} + +{ + // Converting a specific exact time to a calendar date / wall-clock time + let timestamp: Temporal.Instant; +>timestamp : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100_000); +>timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100_000) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>timestamp : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1553993100_000) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1553993100_000 : 1553993100000 +> : ^^^^^^^^^^^^^ + + timestamp.toZonedDateTimeISO("Europe/Berlin"); // => 2019-03-31T01:45:00+01:00[Europe/Berlin] +>timestamp.toZonedDateTimeISO("Europe/Berlin") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>timestamp.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timestamp : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Europe/Berlin" : "Europe/Berlin" +> : ^^^^^^^^^^^^^^^ + + timestamp.toZonedDateTimeISO("UTC"); // => 2019-03-31T00:45:00+00:00[UTC] +>timestamp.toZonedDateTimeISO("UTC") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>timestamp.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timestamp : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"UTC" : "UTC" +> : ^^^^^ + + timestamp.toZonedDateTimeISO("-08:00"); // => 2019-03-30T16:45:00-08:00[-08:00] +>timestamp.toZonedDateTimeISO("-08:00") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>timestamp.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timestamp : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-08:00" : "-08:00" +> : ^^^^^^^^ + + // What time was the Unix epoch (timestamp 0) in Bell Labs (Murray Hill, New Jersey, USA) in the Gregorian calendar? + const epoch = Temporal.Instant.fromEpochMilliseconds(0); +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(0) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>0 : 0 +> : ^ + + epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory"); +>epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("America/New_York").withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("America/New_York") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"America/New_York" : "America/New_York" +> : ^^^^^^^^^^^^^^^^^^ +>withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"gregory" : "gregory" +> : ^^^^^^^^^ + + // => 1969-12-31T19:00:00-05:00[America/New_York][u-ca=gregory] + + // What time was the Unix epoch in Tokyo in the Japanese calendar? + const zdt = epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("Asia/Tokyo") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Tokyo" : "Asia/Tokyo" +> : ^^^^^^^^^^^^ +>withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"japanese" : "japanese" +> : ^^^^^^^^^^ + + // => 1970-01-01T09:00:00+09:00[Asia/Tokyo][u-ca=japanese] + console.log(zdt.eraYear, zdt.era); +>console.log(zdt.eraYear, zdt.era) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>zdt.eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt.era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => '45 showa' +} + +{ + // Temporal.Instant representing five hours from now + Temporal.Now.instant().add({ hours: 5 }); +>Temporal.Now.instant().add({ hours: 5 }) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant().add : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.instant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 5 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>5 : 5 +> : ^ + + const fiveHours = Temporal.Duration.from({ hours: 5 }); +>fiveHours : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 5 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 5 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>5 : 5 +> : ^ + + Temporal.Now.instant().add(fiveHours); +>Temporal.Now.instant().add(fiveHours) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant().add : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.instant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fiveHours : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +} + +{ + // Temporal.Instant representing this time an hour ago + Temporal.Now.instant().subtract({ hours: 1 }); +>Temporal.Now.instant().subtract({ hours: 1 }) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant().subtract : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.instant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 1 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>1 : 1 +> : ^ + + const oneHour = Temporal.Duration.from({ hours: 1 }); +>oneHour : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 1 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>1 : 1 +> : ^ + + Temporal.Now.instant().subtract(oneHour); +>Temporal.Now.instant().subtract(oneHour) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant().subtract : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.instant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneHour : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +} + +{ + const startOfMoonMission = Temporal.Instant.from("1969-07-16T13:32:00Z"); +>startOfMoonMission : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("1969-07-16T13:32:00Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1969-07-16T13:32:00Z" : "1969-07-16T13:32:00Z" +> : ^^^^^^^^^^^^^^^^^^^^^^ + + const endOfMoonMission = Temporal.Instant.from("1969-07-24T16:50:35Z"); +>endOfMoonMission : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("1969-07-24T16:50:35Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1969-07-24T16:50:35Z" : "1969-07-24T16:50:35Z" +> : ^^^^^^^^^^^^^^^^^^^^^^ + + const missionLength = startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }); +>missionLength : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startOfMoonMission.until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startOfMoonMission : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>endOfMoonMission : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // => PT195H18M35S + missionLength.toLocaleString(); +>missionLength.toLocaleString() : string +> : ^^^^^^ +>missionLength.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>missionLength : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + // example output: '195 hours 18 minutes 35 seconds' + + // Rounding, for example if you don't care about the minutes and seconds + const approxMissionLength = startOfMoonMission.until(endOfMoonMission, { +>approxMissionLength : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour", smallestUnit: "hour", }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startOfMoonMission.until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startOfMoonMission : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>endOfMoonMission : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour", smallestUnit: "hour", } : { largestUnit: "hour"; smallestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + largestUnit: "hour", +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + smallestUnit: "hour", +>smallestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + }); + // => PT195H + + // A billion (10^9) seconds since the epoch in different units + const epoch = Temporal.Instant.fromEpochMilliseconds(0); +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(0) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>0 : 0 +> : ^ + + const billion = Temporal.Instant.fromEpochMilliseconds(1e9); +>billion : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1e9) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1e9 : 1000000000 +> : ^^^^^^^^^^ + + epoch.until(billion); +>epoch.until(billion) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>epoch.until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>billion : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ + + // => PT1000000000S + epoch.until(billion, { largestUnit: "hour" }); +>epoch.until(billion, { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>epoch.until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>billion : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // => PT277777H46M40S + const ns = epoch.until(billion, { largestUnit: "nanosecond" }); +>ns : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>epoch.until(billion, { largestUnit: "nanosecond" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>epoch.until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>until : (other: Temporal.InstantLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>billion : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>{ largestUnit: "nanosecond" } : { largestUnit: "nanosecond"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "nanosecond" +> : ^^^^^^^^^^^^ +>"nanosecond" : "nanosecond" +> : ^^^^^^^^^^^^ + + // => PT1000000000S + ns.add({ nanoseconds: 1 }); +>ns.add({ nanoseconds: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>ns.add : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ns : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>add : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ nanoseconds: 1 } : { nanoseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>nanoseconds : number +> : ^^^^^^ +>1 : 1 +> : ^ + + // => PT1000000000S + // (lost precision) + + // Calculate the difference in years, eliminating the ambiguity by + // explicitly using the corresponding calendar date in UTC: + epoch.toZonedDateTimeISO("UTC").until( +>epoch.toZonedDateTimeISO("UTC").until( billion.toZonedDateTimeISO("UTC"), { largestUnit: "year" }, ) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("UTC").until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO("UTC") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epoch.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>epoch : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"UTC" : "UTC" +> : ^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + billion.toZonedDateTimeISO("UTC"), +>billion.toZonedDateTimeISO("UTC") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>billion.toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>billion : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toZonedDateTimeISO : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"UTC" : "UTC" +> : ^^^^^ + + { largestUnit: "year" }, +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + ); + // => P31Y8M8DT1H46M40S +} + +{ + const instant = Temporal.Instant.from("2019-03-30T02:45:59.999999999Z"); +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2019-03-30T02:45:59.999999999Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-30T02:45:59.999999999Z" : "2019-03-30T02:45:59.999999999Z" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // Round to a particular unit + instant.round({ smallestUnit: "second" }); // => 2019-03-30T02:46:00Z +>instant.round({ smallestUnit: "second" }) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant.round : { (roundTo: Temporal.TimeUnit): Temporal.Instant; (roundTo: Temporal.RoundingOptions): Temporal.Instant; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>round : { (roundTo: Temporal.TimeUnit): Temporal.Instant; (roundTo: Temporal.RoundingOptions): Temporal.Instant; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "second" } : { smallestUnit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ + + // Round to an increment of a unit, e.g. an hour: + instant.round({ roundingIncrement: 60, smallestUnit: "minute" }); +>instant.round({ roundingIncrement: 60, smallestUnit: "minute" }) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant.round : { (roundTo: Temporal.TimeUnit): Temporal.Instant; (roundTo: Temporal.RoundingOptions): Temporal.Instant; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>round : { (roundTo: Temporal.TimeUnit): Temporal.Instant; (roundTo: Temporal.RoundingOptions): Temporal.Instant; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 60, smallestUnit: "minute" } : { roundingIncrement: number; smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>60 : 60 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + // => 2019-03-30T03:00:00Z + // Round to the same increment but round down instead: + instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }); +>instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>instant.round : { (roundTo: Temporal.TimeUnit): Temporal.Instant; (roundTo: Temporal.RoundingOptions): Temporal.Instant; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>round : { (roundTo: Temporal.TimeUnit): Temporal.Instant; (roundTo: Temporal.RoundingOptions): Temporal.Instant; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" } : { roundingIncrement: number; smallestUnit: "minute"; roundingMode: "floor"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>60 : 60 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ +>roundingMode : "floor" +> : ^^^^^^^ +>"floor" : "floor" +> : ^^^^^^^ + + // => 2019-03-30T02:00:00Z +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); +>one : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1.0e12) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1.0e12 : 1000000000000 +> : ^^^^^^^^^^^^^ + + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); +>two : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1.1e12) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1.1e12 : 1100000000000 +> : ^^^^^^^^^^^^^ + + one.equals(two); // => false +>one.equals(two) : boolean +> : ^^^^^^^ +>one.equals : (other: Temporal.InstantLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.InstantLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>two : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ + + one.equals(one); // => true +>one.equals(one) : boolean +> : ^^^^^^^ +>one.equals : (other: Temporal.InstantLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.InstantLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +} + +{ + const instant = Temporal.Instant.fromEpochMilliseconds(1574074321816); +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds(1574074321816) : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fromEpochMilliseconds : (epochMilliseconds: number) => Temporal.Instant +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ +>1574074321816 : 1574074321816 +> : ^^^^^^^^^^^^^ + + instant.toString(); // => '2019-11-18T10:52:01.816Z' +>instant.toString() : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + instant.toString({ timeZone: "UTC" }); +>instant.toString({ timeZone: "UTC" }) : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "UTC" } : { timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"UTC" : "UTC" +> : ^^^^^ + + // => '2019-11-18T10:52:01.816+00:00' + instant.toString({ timeZone: "Asia/Seoul" }); +>instant.toString({ timeZone: "Asia/Seoul" }) : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "Asia/Seoul" } : { timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"Asia/Seoul" : "Asia/Seoul" +> : ^^^^^^^^^^^^ + + // => '2019-11-18T19:52:01.816+09:00' + + instant.toString({ smallestUnit: "minute" }); +>instant.toString({ smallestUnit: "minute" }) : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "minute" } : { smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + // => '2019-11-18T10:52Z' + instant.toString({ fractionalSecondDigits: 0 }); +>instant.toString({ fractionalSecondDigits: 0 }) : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 0 } : { fractionalSecondDigits: 0; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 0 +> : ^ +>0 : 0 +> : ^ + + // => '2019-11-18T10:52:01Z' + instant.toString({ fractionalSecondDigits: 4 }); +>instant.toString({ fractionalSecondDigits: 4 }) : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 4 } : { fractionalSecondDigits: 4; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 4 +> : ^ +>4 : 4 +> : ^ + + // => '2019-11-18T10:52:01.8160Z' + instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }); +>instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }) : string +> : ^^^^^^ +>instant.toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.InstantToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "second", roundingMode: "halfExpand" } : { smallestUnit: "second"; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => '2019-11-18T10:52:02Z' +} + +{ + const instant = Temporal.Instant.from("2019-11-18T11:00:00.000Z"); +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from("2019-11-18T11:00:00.000Z") : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Instant.from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Instant : Temporal.InstantConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.InstantLike) => Temporal.Instant +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-11-18T11:00:00.000Z" : "2019-11-18T11:00:00.000Z" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + instant.toLocaleString(); // example output: '2019-11-18, 3:00:00 a.m.' +>instant.toLocaleString() : string +> : ^^^^^^ +>instant.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + instant.toLocaleString("de-DE"); // example output: '18.11.2019, 03:00:00' +>instant.toLocaleString("de-DE") : string +> : ^^^^^^ +>instant.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + instant.toLocaleString("de-DE", { +>instant.toLocaleString("de-DE", { timeZone: "Europe/Berlin", year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", timeZoneName: "long", }) : string +> : ^^^^^^ +>instant.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ timeZone: "Europe/Berlin", year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", timeZoneName: "long", } : { timeZone: string; year: "numeric"; month: "numeric"; day: "numeric"; hour: "numeric"; minute: "numeric"; timeZoneName: "long"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + timeZone: "Europe/Berlin", +>timeZone : string +> : ^^^^^^ +>"Europe/Berlin" : "Europe/Berlin" +> : ^^^^^^^^^^^^^^^ + + year: "numeric", +>year : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ + + month: "numeric", +>month : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ + + day: "numeric", +>day : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ + + hour: "numeric", +>hour : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ + + minute: "numeric", +>minute : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ + + timeZoneName: "long", +>timeZoneName : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ + + }); // => '18.11.2019, 12:00 Mitteleuropäische Normalzeit' + instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { +>instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { timeZone: "Asia/Kolkata", }) : string +> : ^^^^^^ +>instant.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>instant : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en-US-u-nu-fullwide-hc-h12" : "en-US-u-nu-fullwide-hc-h12" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "Asia/Kolkata", } : { timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ + + timeZone: "Asia/Kolkata", +>timeZone : string +> : ^^^^^^ +>"Asia/Kolkata" : "Asia/Kolkata" +> : ^^^^^^^^^^^^^^ + + }); // => '11/18/2019, 4:30:00 PM' +} + +{ + // UNIX epoch in California + new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601"); +>new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>0n : 0n +> : ^^ +>"America/Los_Angeles" : "America/Los_Angeles" +> : ^^^^^^^^^^^^^^^^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ + + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); +>new Temporal.ZonedDateTime(0n, "America/Los_Angeles") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>0n : 0n +> : ^^ +>"America/Los_Angeles" : "America/Los_Angeles" +> : ^^^^^^^^^^^^^^^^^^^^^ + + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + // same, but shorter +} + +{ + let zdt: Temporal.ZonedDateTime; +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); +>zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30+02:00[Africa/Cairo]" : "1995-12-07T03:24:30+02:00[Africa/Cairo]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); +>zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]" : "1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); +>zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19951207T032430+0200[Africa/Cairo]" : "19951207T032430+0200[Africa/Cairo]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt = Temporal.ZonedDateTime.from({ +>zdt = Temporal.ZonedDateTime.from({ timeZone: "America/Los_Angeles", year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from({ timeZone: "America/Los_Angeles", year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "America/Los_Angeles", year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, } : { timeZone: string; year: number; month: number; day: number; hour: number; minute: number; second: number; millisecond: number; microsecond: number; nanosecond: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + timeZone: "America/Los_Angeles", +>timeZone : string +> : ^^^^^^ +>"America/Los_Angeles" : "America/Los_Angeles" +> : ^^^^^^^^^^^^^^^^^^^^^ + + year: 1995, +>year : number +> : ^^^^^^ +>1995 : 1995 +> : ^^^^ + + month: 12, +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ + + day: 7, +>day : number +> : ^^^^^^ +>7 : 7 +> : ^ + + hour: 3, +>hour : number +> : ^^^^^^ +>3 : 3 +> : ^ + + minute: 24, +>minute : number +> : ^^^^^^ +>24 : 24 +> : ^^ + + second: 30, +>second : number +> : ^^^^^^ +>30 : 30 +> : ^^ + + millisecond: 0, +>millisecond : number +> : ^^^^^^ +>0 : 0 +> : ^ + + microsecond: 3, +>microsecond : number +> : ^^^^^^ +>3 : 3 +> : ^ + + nanosecond: 500, +>nanosecond : number +> : ^^^^^^ +>500 : 500 +> : ^^^ + + }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] + + // Different overflow modes + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); +>zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 } : { timeZone: string; year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"Europe/Paris" : "Europe/Paris" +> : ^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-12-01T00:00:00+01:00[Europe/Paris] + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); +>zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 } : { timeZone: string; year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"Europe/Paris" : "Europe/Paris" +> : ^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws RangeError +} + +{ + const arr = [ +>arr : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>[ Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), ] : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), +>Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-02-01T12:30-05:00[America/Toronto]" : "2020-02-01T12:30-05:00[America/Toronto]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), +>Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-02-01T12:30-05:00[America/New_York]" : "2020-02-01T12:30-05:00[America/New_York]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), +>Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-02-01T12:30+01:00[Europe/Brussels]" : "2020-02-01T12:30+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), +>Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-02-01T12:30+00:00[Europe/London]" : "2020-02-01T12:30+00:00[Europe/London]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ]; + const sorted = arr.sort(Temporal.ZonedDateTime.compare); +>sorted : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>arr.sort(Temporal.ZonedDateTime.compare) : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>arr.sort : (compareFn?: ((a: Temporal.ZonedDateTime, b: Temporal.ZonedDateTime) => number) | undefined) => Temporal.ZonedDateTime[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>arr : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.ZonedDateTime, b: Temporal.ZonedDateTime) => number) | undefined) => Temporal.ZonedDateTime[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.compare : (one: Temporal.ZonedDateTimeLike, two: Temporal.ZonedDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.ZonedDateTimeLike, two: Temporal.ZonedDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + JSON.stringify(sorted, undefined, 2); +>JSON.stringify(sorted, undefined, 2) : string +> : ^^^^^^ +>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (number | string)[] | null, space?: string | number): string; } +> : ^^^ ^^ ^^ ^^^ ^^ ^^^ ^^^ ^^^ ^^ ^^ ^^^ ^^ ^^^ ^^^ ^^^ +>JSON : JSON +> : ^^^^ +>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (number | string)[] | null, space?: string | number): string; } +> : ^^^ ^^ ^^ ^^^ ^^ ^^^ ^^^ ^^^ ^^ ^^ ^^^ ^^ ^^^ ^^^ ^^^ +>sorted : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>undefined : undefined +> : ^^^^^^^^^ +>2 : 2 +> : ^ + + // => + // '[ + // "2020-02-01T12:30+01:00[Europe/Brussels]", + // "2020-02-01T12:30+00:00[Europe/London]", + // "2020-02-01T12:30-05:00[America/Toronto]", + // "2020-02-01T12:30-05:00[America/New_York]" + // ]' +} + +{ + const dt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]"); +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500[Europe/Rome]" : "1995-12-07T03:24:30.000003500[Europe/Rome]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.year; // => 1995 +>dt.year : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + dt.month; // => 12 +>dt.month : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + dt.monthCode; // => 'M12' +>dt.monthCode : string +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + dt.day; // => 7 +>dt.day : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + dt.hour; // => 3 +>dt.hour : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ + + dt.minute; // => 24 +>dt.minute : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>minute : number +> : ^^^^^^ + + dt.second; // => 30 +>dt.second : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>second : number +> : ^^^^^^ + + dt.millisecond; // => 0 +>dt.millisecond : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>millisecond : number +> : ^^^^^^ + + dt.microsecond; // => 3 +>dt.microsecond : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>microsecond : number +> : ^^^^^^ + + dt.nanosecond; // => 500 +>dt.nanosecond : number +> : ^^^^^^ +>dt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>nanosecond : number +> : ^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-02-01T12:30+09:00[Asia/Tokyo]" : "2020-02-01T12:30+09:00[Asia/Tokyo]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const epochMs = zdt.epochMilliseconds; +>epochMs : number +> : ^^^^^^ +>zdt.epochMilliseconds : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epochMilliseconds : number +> : ^^^^^^ + + // => 1580527800000 + zdt.toInstant().epochMilliseconds; +>zdt.toInstant().epochMilliseconds : number +> : ^^^^^^ +>zdt.toInstant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>zdt.toInstant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toInstant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epochMilliseconds : number +> : ^^^^^^ + + // => 1580527800000 + const legacyDate = new Date(epochMs); +>legacyDate : Date +> : ^^^^ +>new Date(epochMs) : Date +> : ^^^^ +>Date : DateConstructor +> : ^^^^^^^^^^^^^^^ +>epochMs : number +> : ^^^^^^ + + // => 2020-02-01T03:30:00.000Z + // (if the system time zone is America/Los_Angeles) + const epochNanos = zdt.epochNanoseconds; +>epochNanos : bigint +> : ^^^^^^ +>zdt.epochNanoseconds : bigint +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epochNanoseconds : bigint +> : ^^^^^^ + + // => 1580527800000000000n + + // If you need epoch seconds data: + const epochSecs = Math.floor(zdt.epochMilliseconds / 1000); // => 1553906700 +>epochSecs : number +> : ^^^^^^ +>Math.floor(zdt.epochMilliseconds / 1000) : number +> : ^^^^^^ +>Math.floor : (x: number) => number +> : ^ ^^ ^^^^^ +>Math : Math +> : ^^^^ +>floor : (x: number) => number +> : ^ ^^ ^^^^^ +>zdt.epochMilliseconds / 1000 : number +> : ^^^^^^ +>zdt.epochMilliseconds : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epochMilliseconds : number +> : ^^^^^^ +>1000 : 1000 +> : ^^^^ + + // => 1580527800 + + // If you need epoch microseconds data: + // (Note the extra check for correct floor rounding with bigints) + const ns = zdt.epochNanoseconds; +>ns : bigint +> : ^^^^^^ +>zdt.epochNanoseconds : bigint +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>epochNanoseconds : bigint +> : ^^^^^^ + + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +>epochMicros : bigint +> : ^^^^^^ +>ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n) : bigint +> : ^^^^^^ +>ns / 1000n : bigint +> : ^^^^^^ +>ns : bigint +> : ^^^^^^ +>1000n : 1000n +> : ^^^^^ +>((ns % 1000n) < 0n ? -1n : 0n) : 0n | -1n +> : ^^^^^^^^ +>(ns % 1000n) < 0n ? -1n : 0n : 0n | -1n +> : ^^^^^^^^ +>(ns % 1000n) < 0n : boolean +> : ^^^^^^^ +>(ns % 1000n) : bigint +> : ^^^^^^ +>ns % 1000n : bigint +> : ^^^^^^ +>ns : bigint +> : ^^^^^^ +>1000n : 1000n +> : ^^^^^ +>0n : 0n +> : ^^ +>-1n : -1n +> : ^^^ +>1n : 1n +> : ^^ +>0n : 0n +> : ^^ + + // => 1580527800000000n +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24-08:00[America/Los_Angeles]" : "1995-12-07T03:24-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + `Time zone is: ${zdt.timeZoneId}`; +>`Time zone is: ${zdt.timeZoneId}` : string +> : ^^^^^^ +>zdt.timeZoneId : string +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => 'Time zone is: America/Los_Angeles' + zdt.withTimeZone("Asia/Kolkata").timeZoneId; +>zdt.withTimeZone("Asia/Kolkata").timeZoneId : string +> : ^^^^^^ +>zdt.withTimeZone("Asia/Kolkata") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Kolkata" : "Asia/Kolkata" +> : ^^^^^^^^^^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => Asia/Kolkata + zdt.withTimeZone("Asia/Calcutta").timeZoneId; +>zdt.withTimeZone("Asia/Calcutta").timeZoneId : string +> : ^^^^^^ +>zdt.withTimeZone("Asia/Calcutta") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Calcutta" : "Asia/Calcutta" +> : ^^^^^^^^^^^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => Asia/Calcutta (does not follow links in the IANA Time Zone Database) + + zdt.withTimeZone("europe/paris").timeZoneId; +>zdt.withTimeZone("europe/paris").timeZoneId : string +> : ^^^^^^ +>zdt.withTimeZone("europe/paris") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"europe/paris" : "europe/paris" +> : ^^^^^^^^^^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => Europe/Paris (normalized to match IANA Time Zone Database capitalization) + + zdt.withTimeZone("+05:00").timeZoneId; +>zdt.withTimeZone("+05:00").timeZoneId : string +> : ^^^^^^ +>zdt.withTimeZone("+05:00") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+05:00" : "+05:00" +> : ^^^^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => +05:00 + zdt.withTimeZone("+05").timeZoneId; +>zdt.withTimeZone("+05").timeZoneId : string +> : ^^^^^^ +>zdt.withTimeZone("+05") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+05" : "+05" +> : ^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => +05:00 (normalized to ±HH:MM) + zdt.withTimeZone("+0500").timeZoneId; +>zdt.withTimeZone("+0500").timeZoneId : string +> : ^^^^^^ +>zdt.withTimeZone("+0500") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+0500" : "+0500" +> : ^^^^^^^ +>timeZoneId : string +> : ^^^^^^ + + // => +05:00 (normalized to ±HH:MM) +} + +{ + const date = Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]"); +>date : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-000015-01-01T12:30[Europe/Rome][u-ca=gregory]" : "-000015-01-01T12:30[Europe/Rome][u-ca=gregory]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.era; +>date.era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 'bce' + date.eraYear; +>date.eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 16 + date.year; +>date.year : number +> : ^^^^^^ +>date : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + // => -15 +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24-08:00[America/Los_Angeles]" : "1995-12-07T03:24-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1]; // => 'THU' +>["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1] : string +> : ^^^^^^ +>["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"] : string[] +> : ^^^^^^^^ +>"MON" : "MON" +> : ^^^^^ +>"TUE" : "TUE" +> : ^^^^^ +>"WED" : "WED" +> : ^^^^^ +>"THU" : "THU" +> : ^^^^^ +>"FRI" : "FRI" +> : ^^^^^ +>"SAT" : "SAT" +> : ^^^^^ +>"SUN" : "SUN" +> : ^^^^^ +>zdt.dayOfWeek - 1 : number +> : ^^^^^^ +>zdt.dayOfWeek : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfWeek : number +> : ^^^^^^ +>1 : 1 +> : ^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24-08:00[America/Los_Angeles]" : "1995-12-07T03:24-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // ISO ordinal date + console.log(zdt.year, zdt.dayOfYear); // => '1995 341' +>console.log(zdt.year, zdt.dayOfYear) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>zdt.year : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>zdt.dayOfYear : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfYear : number +> : ^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2022-01-01T03:24-08:00[America/Los_Angeles]" : "2022-01-01T03:24-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // ISO week date + console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek); // => '2021 52 6' +>console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>zdt.yearOfWeek : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>yearOfWeek : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt.weekOfYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>weekOfYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt.dayOfWeek : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfWeek : number +> : ^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24-08:00[America/Los_Angeles]" : "1995-12-07T03:24-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.daysInWeek; // => 7 +>zdt.daysInWeek : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInWeek : number +> : ^^^^^^ +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ +>{} : {} +> : ^^ + + for (let month = 1; month <= 12; month++) { +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>month <= 12 : boolean +> : ^^^^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>month++ : number +> : ^^^^^^ +>month : number +> : ^^^^^^ + + const zdt = Temporal.Now.zonedDateTimeISO().with({ month }); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO().with({ month }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO().with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO() : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month } : { month: number; } +> : ^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt); +>monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt) : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[zdt.daysInMonth] : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.daysInMonth : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>(monthsByDays[zdt.daysInMonth] || []).concat(zdt) : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[zdt.daysInMonth] || []).concat : { (...items: ConcatArray[]): Temporal.ZonedDateTime[]; (...items: (Temporal.ZonedDateTime | ConcatArray)[]): Temporal.ZonedDateTime[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[zdt.daysInMonth] || []) : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[zdt.daysInMonth] || [] : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[zdt.daysInMonth] : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.daysInMonth : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>[] : never[] +> : ^^^^^^^ +>concat : { (...items: ConcatArray[]): Temporal.ZonedDateTime[]; (...items: (Temporal.ZonedDateTime | ConcatArray)[]): Temporal.ZonedDateTime[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + } + + const strings = monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })); +>strings : string[] +> : ^^^^^^^^ +>monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })) : string[] +> : ^^^^^^^^ +>monthsByDays[30].map : (callbackfn: (value: Temporal.ZonedDateTime, index: number, array: Temporal.ZonedDateTime[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>monthsByDays[30] : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>30 : 30 +> : ^^ +>map : (callbackfn: (value: Temporal.ZonedDateTime, index: number, array: Temporal.ZonedDateTime[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>zdt => zdt.toLocaleString("en", { month: "long" }) : (zdt: Temporal.ZonedDateTime) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.toLocaleString("en", { month: "long" }) : string +> : ^^^^^^ +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ month: "long" } : { month: "long"; } +> : ^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift(strings.pop()!) : number +> : ^^^^^^ +>strings.unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings.pop()! : string +> : ^^^^^^ +>strings.pop() : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>strings.pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + const format = new Intl.ListFormat("en"); +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>new Intl.ListFormat("en") : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>Intl.ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>Intl : typeof Intl +> : ^^^^^^^^^^^ +>ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>"en" : "en" +> : ^^^^ + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : string +> : ^^^^^^ +>`Thirty days hath ${format.format(strings)}` : string +> : ^^^^^^ +>format.format(strings) : string +> : ^^^^^^ +>format.format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>strings : string[] +> : ^^^^^^^^ + + console.log(poem); +>console.log(poem) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>poem : string +> : ^^^^^^ +} + +{ + const zdt = Temporal.Now.zonedDateTimeISO(); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO() : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const percent = zdt.dayOfYear / zdt.daysInYear; +>percent : number +> : ^^^^^^ +>zdt.dayOfYear / zdt.daysInYear : number +> : ^^^^^^ +>zdt.dayOfYear : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfYear : number +> : ^^^^^^ +>zdt.daysInYear : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInYear : number +> : ^^^^^^ + + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; +>`The year is ${percent.toLocaleString("en", { style: "percent" })} over!` : string +> : ^^^^^^ +>percent.toLocaleString("en", { style: "percent" }) : string +> : ^^^^^^ +>percent.toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>percent : number +> : ^^^^^^ +>toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ style: "percent" } : { style: "percent"; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>style : "percent" +> : ^^^^^^^^^ +>"percent" : "percent" +> : ^^^^^^^^^ + + // example output: "The year is 10% over!" +} + +{ + const zdt = Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1900-01-01T12:00+09:00[Asia/Tokyo]" : "1900-01-01T12:00+09:00[Asia/Tokyo]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.monthsInYear; // => 12 +>zdt.monthsInYear : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthsInYear : number +> : ^^^^^^ +} + +{ + // Is this year a leap year? + const zdt = Temporal.Now.zonedDateTimeISO(); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO() : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.inLeapYear; // example output: true +>zdt.inLeapYear : boolean +> : ^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>inLeapYear : boolean +> : ^^^^^^^ + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + zdt.with({ year: 2100 }).inLeapYear; // => false +>zdt.with({ year: 2100 }).inLeapYear : boolean +> : ^^^^^^^ +>zdt.with({ year: 2100 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2100 } : { year: number; } +> : ^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2100 : 2100 +> : ^^^^ +>inLeapYear : boolean +> : ^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2010-11-07T23:00:00-03:30[America/St_Johns]" : "2010-11-07T23:00:00-03:30[America/St_Johns]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.hoursInDay; // 25 +>zdt.hoursInDay : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>hoursInDay : number +> : ^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-11-01T01:30-07:00[America/Los_Angeles]" : "2020-11-01T01:30-07:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.offsetNanoseconds; +>zdt.offsetNanoseconds : number +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>offsetNanoseconds : number +> : ^^^^^^ + + // => -25200000000000 + // (-7 * 3600 * 1e9) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-11-01T01:30-07:00[America/Los_Angeles]" : "2020-11-01T01:30-07:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.offset; +>zdt.offset : string +> : ^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>offset : string +> : ^^^^^^ + + // => '-07:00' + zdt.withTimeZone("Asia/Kolkata").offset; +>zdt.withTimeZone("Asia/Kolkata").offset : string +> : ^^^^^^ +>zdt.withTimeZone("Asia/Kolkata") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Kolkata" : "Asia/Kolkata" +> : ^^^^^^^^^^^^^^ +>offset : string +> : ^^^^^^ + + // => '+05:30' + + const minus8Hours = "-08:00"; +>minus8Hours : "-08:00" +> : ^^^^^^^^ +>"-08:00" : "-08:00" +> : ^^^^^^^^ + + const daylightTime0130 = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); +>daylightTime0130 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-11-01T01:30-07:00[America/Los_Angeles]" : "2020-11-01T01:30-07:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 2020-11-01T01:30:00-07:00[America/Los_Angeles] + // This is Pacific Daylight Time 1:30AM + const repeated0130 = daylightTime0130.with({ offset: minus8Hours }); +>repeated0130 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daylightTime0130.with({ offset: minus8Hours }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daylightTime0130.with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>daylightTime0130 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ offset: minus8Hours } : { offset: string; } +> : ^^^^^^^^^^^^^^^^^^^ +>offset : string +> : ^^^^^^ +>minus8Hours : "-08:00" +> : ^^^^^^^^ + + // => 2020-11-01T01:30:00-08:00[America/Los_Angeles] + // This is Pacific Standard Time 1:30AM +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:00-06:00[America/Chicago]" : "1995-12-07T03:24:00-06:00[America/Chicago]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.with({ year: 2015, minute: 31 }); // => 2015-12-07T03:31:00-06:00[America/Chicago] +>zdt.with({ year: 2015, minute: 31 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>with : (zonedDateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2015, minute: 31 } : { year: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2015 : 2015 +> : ^^^^ +>minute : number +> : ^^^^^^ +>31 : 31 +> : ^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]" : "2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00-08:00[America/Los_Angeles] +>zdt.withPlainTime({ hour: 10 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 10 } : { hour: number; } +> : ^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>10 : 10 +> : ^^ + + const time = Temporal.PlainTime.from("11:22"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("11:22") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"11:22" : "11:22" +> : ^^^^^^^ + + zdt.withPlainTime(time); // => 2015-12-07T11:22:00-08:00[America/Los_Angeles] +>zdt.withPlainTime(time) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + zdt.withPlainTime("12:34"); // => 2015-12-07T12:34:00-08:00[America/Los_Angeles] +>zdt.withPlainTime("12:34") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"12:34" : "12:34" +> : ^^^^^^^ + + // easier for chaining + zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00-08:00[America/Los_Angeles] +>zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add({ days: 2, hours: 22 }).withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add({ days: 2, hours: 22 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 2, hours: 22 } : { days: number; hours: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>2 : 2 +> : ^ +>hours : number +> : ^^^^^^ +>22 : 22 +> : ^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"00:00" : "00:00" +> : ^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30+09:00[Asia/Tokyo]" : "1995-12-07T03:24:30+09:00[Asia/Tokyo]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]' +>zdt.toString() : string +> : ^^^^^^ +>zdt.toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.withTimeZone("Africa/Accra").toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]' +>zdt.withTimeZone("Africa/Accra").toString() : string +> : ^^^^^^ +>zdt.withTimeZone("Africa/Accra").toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone("Africa/Accra") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Africa/Accra" : "Africa/Accra" +> : ^^^^^^^^^^^^^^ +>toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]" : "1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + `${zdt.era} ${zdt.eraYear}`; // => 'heisei 7' +>`${zdt.era} ${zdt.eraYear}` : string +> : ^^^^^^ +>zdt.era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt.eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ + + zdt.withCalendar("gregory").eraYear; // => 1995 +>zdt.withCalendar("gregory").eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>zdt.withCalendar("gregory") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"gregory" : "gregory" +> : ^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-03-08T00:00-08:00[America/Los_Angeles]" : "2020-03-08T00:00-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // Add a day to get midnight on the day after DST starts + const laterDay = zdt.add({ days: 1 }); +>laterDay : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add({ days: 1 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 1 } : { days: number; } +> : ^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>1 : 1 +> : ^ + + // => 2020-03-09T00:00:00-07:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + laterDay.since(zdt, { largestUnit: "hour" }).hours; +>laterDay.since(zdt, { largestUnit: "hour" }).hours : number +> : ^^^^^^ +>laterDay.since(zdt, { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>laterDay.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>laterDay : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ +>hours : number +> : ^^^^^^ + + // => 23 + // because one clock hour lost to DST + + const laterHours = zdt.add({ hours: 24 }); +>laterHours : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add({ hours: 24 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 24 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>24 : 24 +> : ^^ + + // => 2020-03-09T01:00:00-07:00[America/Los_Angeles] + // Adding time units doesn't adjust for DST. Result is 1:00AM: 24 real-world + // hours later because a clock hour was skipped by DST. + laterHours.since(zdt, { largestUnit: "hour" }).hours; // => 24 +>laterHours.since(zdt, { largestUnit: "hour" }).hours : number +> : ^^^^^^ +>laterHours.since(zdt, { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>laterHours.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>laterHours : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ +>hours : number +> : ^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-03-09T00:00-07:00[America/Los_Angeles]" : "2020-03-09T00:00-07:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // Add a day to get midnight on the day after DST starts + const earlierDay = zdt.subtract({ days: 1 }); +>earlierDay : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.subtract({ days: 1 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 1 } : { days: number; } +> : ^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>1 : 1 +> : ^ + + // => 2020-03-08T00:00:00-08:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + earlierDay.since(zdt, { largestUnit: "hour" }).hours; +>earlierDay.since(zdt, { largestUnit: "hour" }).hours : number +> : ^^^^^^ +>earlierDay.since(zdt, { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>earlierDay.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlierDay : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ +>hours : number +> : ^^^^^^ + + // => -23 + // because one clock hour lost to DST + + const earlierHours = zdt.subtract({ hours: 24 }); +>earlierHours : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.subtract({ hours: 24 }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 24 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>24 : 24 +> : ^^ + + // => 2020-03-07T23:00:00-08:00[America/Los_Angeles] + // Subtracting time units doesn't adjust for DST. Result is 11:00PM: 24 real-world + // hours earlier because a clock hour was skipped by DST. + earlierHours.since(zdt, { largestUnit: "hour" }).hours; // => -24 +>earlierHours.since(zdt, { largestUnit: "hour" }).hours : number +> : ^^^^^^ +>earlierHours.since(zdt, { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>earlierHours.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlierHours : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ +>hours : number +> : ^^^^^^ +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]" : "1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31T15:30+05:30[Asia/Kolkata]" : "2019-01-31T15:30+05:30[Asia/Kolkata]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt1.until(zdt2); +>zdt1.until(zdt2) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>zdt1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + // => PT202956H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "year" }); +>zdt1.until(zdt2, { largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>zdt1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + // => P23Y1M24DT12H5M29.9999965S + zdt2.until(zdt1, { largestUnit: "year" }); +>zdt2.until(zdt1, { largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>zdt2.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + // => -P23Y1M24DT12H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "nanosecond" }); +>zdt1.until(zdt2, { largestUnit: "nanosecond" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>zdt1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "nanosecond" } : { largestUnit: "nanosecond"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "nanosecond" +> : ^^^^^^^^^^^^ +>"nanosecond" : "nanosecond" +> : ^^^^^^^^^^^^ + + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + zdt1.until(zdt2, { smallestUnit: "second" }); +>zdt1.until(zdt2, { smallestUnit: "second" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>zdt1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "second" } : { smallestUnit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ + + // => PT202956H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })); +>jan1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>[1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })) : Temporal.ZonedDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>[1, 2, 3].map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>[1, 2, 3] : number[] +> : ^^^^^^^^ +>1 : 1 +> : ^ +>2 : 2 +> : ^ +>3 : 3 +> : ^ +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" }) : (month: number) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2020, month, day: 1, timeZone: "Asia/Seoul" } : { year: number; month: number; day: number; timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2020 : 2020 +> : ^^^^ +>month : number +> : ^^^^^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>timeZone : string +> : ^^^^^^ +>"Asia/Seoul" : "Asia/Seoul" +> : ^^^^^^^^^^^^ + + jan1.until(feb1, { largestUnit: "day" }); // => P31D +>jan1.until(feb1, { largestUnit: "day" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>jan1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>jan1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "day" } : { largestUnit: "day"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "day" +> : ^^^^^ +>"day" : "day" +> : ^^^^^ + + jan1.until(feb1, { largestUnit: "month" }); // => P1M +>jan1.until(feb1, { largestUnit: "month" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>jan1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>jan1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "month" } : { largestUnit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + feb1.until(mar1, { largestUnit: "day" }); // => P29D +>feb1.until(mar1, { largestUnit: "day" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>feb1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "day" } : { largestUnit: "day"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "day" +> : ^^^^^ +>"day" : "day" +> : ^^^^^ + + feb1.until(mar1, { largestUnit: "month" }); // => P1M +>feb1.until(mar1, { largestUnit: "month" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>feb1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "month" } : { largestUnit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + jan1.until(mar1, { largestUnit: "day" }); // => P60D +>jan1.until(mar1, { largestUnit: "day" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>jan1.until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>jan1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "day" } : { largestUnit: "day"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "day" +> : ^^^^^ +>"day" : "day" +> : ^^^^^ +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]" : "1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31T15:30+05:30[Asia/Kolkata]" : "2019-01-31T15:30+05:30[Asia/Kolkata]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt2.since(zdt1); // => PT202956H5M29.9999965S +>zdt2.since(zdt1) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>zdt2.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]" : "1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // Round to a particular unit + zdt.round({ smallestUnit: "hour" }); +>zdt.round({ smallestUnit: "hour" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.ZonedDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.ZonedDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.ZonedDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.ZonedDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "hour" } : { smallestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + // Round to an increment of a unit, e.g. half an hour: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }); +>zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.ZonedDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.ZonedDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.ZonedDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.ZonedDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 30, smallestUnit: "minute" } : { roundingIncrement: number; smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + // => 1995-12-07T03:30:00-08:00[America/Los_Angeles] + // Round to the same increment but round down instead: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); +>zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.ZonedDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.ZonedDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.ZonedDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.ZonedDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" } : { roundingIncrement: number; smallestUnit: "minute"; roundingMode: "floor"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ +>roundingMode : "floor" +> : ^^^^^^^ +>"floor" : "floor" +> : ^^^^^^^ + + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2015-10-18T12:00-02:00[America/Sao_Paulo]" : "2015-10-18T12:00-02:00[America/Sao_Paulo]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] +>zdt.startOfDay() : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.startOfDay : () => Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>startOfDay : () => Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + let duration: Temporal.Duration; +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + // How long until the next offset change from now, in the current location? + const tz = Temporal.Now.timeZoneId(); +>tz : string +> : ^^^^^^ +>Temporal.Now.timeZoneId() : string +> : ^^^^^^ +>Temporal.Now.timeZoneId : () => string +> : ^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>timeZoneId : () => string +> : ^^^^^^ + + const now = Temporal.Now.zonedDateTimeISO(tz); +>now : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO(tz) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>tz : string +> : ^^^^^^ + + const nextTransition = now.getTimeZoneTransition("next"); +>nextTransition : Temporal.ZonedDateTime | null +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>now.getTimeZoneTransition("next") : Temporal.ZonedDateTime | null +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>now.getTimeZoneTransition : { (direction: "next" | "previous"): Temporal.ZonedDateTime | null; (direction: Temporal.TransitionOptions): Temporal.ZonedDateTime | null; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>now : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>getTimeZoneTransition : { (direction: "next" | "previous"): Temporal.ZonedDateTime | null; (direction: Temporal.TransitionOptions): Temporal.ZonedDateTime | null; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>"next" : "next" +> : ^^^^^^ + + duration = nextTransition!.since(now); +>duration = nextTransition!.since(now) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>nextTransition!.since(now) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>nextTransition!.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>nextTransition! : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>nextTransition : Temporal.ZonedDateTime | null +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>now : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + duration.toLocaleString(); // output will vary +>duration.toLocaleString() : string +> : ^^^^^^ +>duration.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + // How long until the previous offset change from now, in the current location? + const previousTransition = now.getTimeZoneTransition("previous"); +>previousTransition : Temporal.ZonedDateTime | null +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>now.getTimeZoneTransition("previous") : Temporal.ZonedDateTime | null +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>now.getTimeZoneTransition : { (direction: "next" | "previous"): Temporal.ZonedDateTime | null; (direction: Temporal.TransitionOptions): Temporal.ZonedDateTime | null; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>now : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>getTimeZoneTransition : { (direction: "next" | "previous"): Temporal.ZonedDateTime | null; (direction: Temporal.TransitionOptions): Temporal.ZonedDateTime | null; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>"previous" : "previous" +> : ^^^^^^^^^^ + + duration = now.since(previousTransition!); +>duration = now.since(previousTransition!) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>now.since(previousTransition!) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>now.since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>now : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.ZonedDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>previousTransition! : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>previousTransition : Temporal.ZonedDateTime | null +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + duration.toLocaleString(); // output will vary +>duration.toLocaleString() : string +> : ^^^^^^ +>duration.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]"); +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500+01:00[Europe/Paris]" : "1995-12-07T03:24:30.000003500+01:00[Europe/Paris]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const zdt2 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]"); +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]" : "1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt1.equals(zdt2); // => false (same offset but different time zones) +>zdt1.equals(zdt2) : boolean +> : ^^^^^^^ +>zdt1.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt2 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + zdt1.equals(zdt1); // => true +>zdt1.equals(zdt1) : boolean +> : ^^^^^^^ +>zdt1.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + // To compare time zone IDs, use withTimeZone() with each ID on the same + // ZonedDateTime instance, and use equals() to compare + const kolkata = zdt1.withTimeZone("Asia/Kolkata"); +>kolkata : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("Asia/Kolkata") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Kolkata" : "Asia/Kolkata" +> : ^^^^^^^^^^^^^^ + + kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")); // => true +>kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")) : boolean +> : ^^^^^^^ +>kolkata.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>kolkata : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("Asia/Calcutta") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Asia/Calcutta" : "Asia/Calcutta" +> : ^^^^^^^^^^^^^^^ + + // Offset time zones are never equivalent to named time zones + kolkata.equals(zdt1.withTimeZone("+05:30")); // => false +>kolkata.equals(zdt1.withTimeZone("+05:30")) : boolean +> : ^^^^^^^ +>kolkata.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>kolkata : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("+05:30") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+05:30" : "+05:30" +> : ^^^^^^^^ + + const zeroOffset = zdt1.withTimeZone("+00:00"); +>zeroOffset : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("+00:00") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+00:00" : "+00:00" +> : ^^^^^^^^ + + zeroOffset.equals(zdt1.withTimeZone("UTC")); // => false +>zeroOffset.equals(zdt1.withTimeZone("UTC")) : boolean +> : ^^^^^^^ +>zeroOffset.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zeroOffset : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("UTC") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"UTC" : "UTC" +> : ^^^^^ + + // For offset time zones, any valid format is accepted + zeroOffset.equals(zdt1.withTimeZone("+00:00")); // => true +>zeroOffset.equals(zdt1.withTimeZone("+00:00")) : boolean +> : ^^^^^^^ +>zeroOffset.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zeroOffset : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("+00:00") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+00:00" : "+00:00" +> : ^^^^^^^^ + + zeroOffset.equals(zdt1.withTimeZone("+0000")); // => true +>zeroOffset.equals(zdt1.withTimeZone("+0000")) : boolean +> : ^^^^^^^ +>zeroOffset.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zeroOffset : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("+0000") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+0000" : "+0000" +> : ^^^^^^^ + + zeroOffset.equals(zdt1.withTimeZone("+00")); // => true +>zeroOffset.equals(zdt1.withTimeZone("+00")) : boolean +> : ^^^^^^^ +>zeroOffset.equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zeroOffset : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.ZonedDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone("+00") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt1.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt1 : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"+00" : "+00" +> : ^^^^^ +} + +{ + let zdt: Temporal.ZonedDateTime; +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }); +>zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" } : { year: number; month: number; day: number; hour: number; timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2019 : 2019 +> : ^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>hour : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>timeZone : string +> : ^^^^^^ +>"Africa/Lagos" : "Africa/Lagos" +> : ^^^^^^^^^^^^^^ + + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos]' +>zdt.toString() : string +> : ^^^^^^ +>zdt.toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt = zdt.withCalendar("japanese"); +>zdt = zdt.withCalendar("japanese") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withCalendar("japanese") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withCalendar : (calendar: Temporal.CalendarLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"japanese" : "japanese" +> : ^^^^^^^^^^ + + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos][u-ca=japanese]' +>zdt.toString() : string +> : ^^^^^^ +>zdt.toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.ZonedDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-12-01T12:00+01:00[Europe/Berlin]" : "2019-12-01T12:00+01:00[Europe/Berlin]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM +>zdt.toLocaleString() : string +> : ^^^^^^ +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' +>zdt.toLocaleString("de-DE") : string +> : ^^^^^^ +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; +>options : { readonly weekday: "long"; readonly year: "numeric"; readonly month: "long"; readonly day: "numeric"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ weekday: "long", year: "numeric", month: "long", day: "numeric" } as const : { readonly weekday: "long"; readonly year: "numeric"; readonly month: "long"; readonly day: "numeric"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ weekday: "long", year: "numeric", month: "long", day: "numeric" } : { readonly weekday: "long"; readonly year: "numeric"; readonly month: "long"; readonly day: "numeric"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>weekday : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ +>year : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ +>day : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ + + zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' +>zdt.toLocaleString("de-DE", options) : string +> : ^^^^^^ +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>options : { readonly weekday: "long"; readonly year: "numeric"; readonly month: "long"; readonly day: "numeric"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); +>zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }) : string +> : ^^^^^^ +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ timeZone: "Pacific/Auckland" } : { timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"Pacific/Auckland" : "Pacific/Auckland" +> : ^^^^^^^^^^^^^^^^^^ + + // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin + zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' +>zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE") : string +> : ^^^^^^ +>zdt.withTimeZone("Pacific/Auckland").toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt.withTimeZone("Pacific/Auckland") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withTimeZone : (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"Pacific/Auckland" : "Pacific/Auckland" +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' +>zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12") : string +> : ^^^^^^ +>zdt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en-US-u-nu-fullwide-hc-h12" : "en-US-u-nu-fullwide-hc-h12" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]"); +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30+02:00[Africa/Johannesburg]" : "1995-12-07T03:24:30+02:00[Africa/Johannesburg]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toInstant(); // => 1995-12-07T01:24:30Z +>zdt.toInstant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>zdt.toInstant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toInstant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toPlainDateTime(); // => 1995-12-07T03:24:30 +>zdt.toPlainDateTime() : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDateTime : () => Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDateTime : () => Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toPlainDate(); // => 1995-12-07 +>zdt.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toPlainTime(); // => 03:24:30 +>zdt.toPlainTime() : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>zdt.toPlainTime : () => Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainTime : () => Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 +>zdt.toPlainDate().toPlainYearMonth() : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate().toPlainYearMonth : () => Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainYearMonth : () => Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + zdt.toPlainDate().toPlainMonthDay(); // => 12-07 +>zdt.toPlainDate().toPlainMonthDay() : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate().toPlainMonthDay : () => Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>zdt.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>zdt : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainMonthDay : () => Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + // Pi day in 2020 + const date = new Temporal.PlainDate(2020, 3, 14); // => 2020-03-14 +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>new Temporal.PlainDate(2020, 3, 14) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>2020 : 2020 +> : ^^^^ +>3 : 3 +> : ^ +>14 : 14 +> : ^^ +} + +{ + let date: Temporal.PlainDate; +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + date = Temporal.PlainDate.from("2006-08-24"); // => 2006-08-24 +>date = Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date = Temporal.PlainDate.from("20060824"); // => 2006-08-24 +>date = Temporal.PlainDate.from("20060824") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("20060824") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"20060824" : "20060824" +> : ^^^^^^^^^^ + + date = Temporal.PlainDate.from("2006-08-24T15:43:27"); // => 2006-08-24 +>date = Temporal.PlainDate.from("2006-08-24T15:43:27") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24T15:43:27") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24T15:43:27" : "2006-08-24T15:43:27" +> : ^^^^^^^^^^^^^^^^^^^^^ + + date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); +>date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24T15:43:27+01:00[Europe/Brussels]" : "2006-08-24T15:43:27+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 2006-08-24 + date === Temporal.PlainDate.from(date); // => false +>date === Temporal.PlainDate.from(date) : boolean +> : ^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from(date) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ + + date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24 +>date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2006, month: 8, day: 24 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2006 : 2006 +> : ^^^^ +>month : number +> : ^^^^^^ +>8 : 8 +> : ^ +>day : number +> : ^^^^^^ +>24 : 24 +> : ^^ + + date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")); +>date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2006-08-24T15:43:27") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24T15:43:27" : "2006-08-24T15:43:27" +> : ^^^^^^^^^^^^^^^^^^^^^ + + // => 2006-08-24 + // same as above; Temporal.PlainDateTime has year, month, and day properties + + date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }); +>date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 1427, month: 8, day: 1, calendar: "islamic" } : { year: number; month: number; day: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>1427 : 1427 +> : ^^^^ +>month : number +> : ^^^^^^ +>8 : 8 +> : ^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>calendar : string +> : ^^^^^^ +>"islamic" : "islamic" +> : ^^^^^^^^^ + + // => 2006-08-24[u-ca=islamic] + + // Different overflow modes + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); +>date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 13, day: 1 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-12-01 + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); +>date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 32 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>32 : 32 +> : ^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-01-31 + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); +>date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 13, day: 1 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); +>date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 32 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>32 : 32 +> : ^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws +} + +{ + const one = Temporal.PlainDate.from("2006-08-24"); +>one : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + const two = Temporal.PlainDate.from("2015-07-14"); +>two : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2015-07-14") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2015-07-14" : "2015-07-14" +> : ^^^^^^^^^^^^ + + const three = Temporal.PlainDate.from("1930-02-18"); +>three : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("1930-02-18") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1930-02-18" : "1930-02-18" +> : ^^^^^^^^^^^^ + + const sorted = [one, two, three].sort(Temporal.PlainDate.compare); +>sorted : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort(Temporal.PlainDate.compare) : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort : (compareFn?: ((a: Temporal.PlainDate, b: Temporal.PlainDate) => number) | undefined) => Temporal.PlainDate[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three] : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>two : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>three : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.PlainDate, b: Temporal.PlainDate) => number) | undefined) => Temporal.PlainDate[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.compare : (one: Temporal.PlainDateLike, two: Temporal.PlainDateLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.PlainDateLike, two: Temporal.PlainDateLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + sorted.join(" "); // => '1930-02-18 2006-08-24 2015-07-14' +>sorted.join(" ") : string +> : ^^^^^^ +>sorted.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ +} + +{ + let date: Temporal.PlainDate; +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + date = Temporal.PlainDate.from("2006-08-24"); +>date = Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.year; // => 2006 +>date.year : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + date.month; // => 8 +>date.month : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + date.monthCode; // => 'M08' +>date.monthCode : string +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + date.day; // => 24 +>date.day : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]"); +>date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-02-23[u-ca=hebrew]" : "2019-02-23[u-ca=hebrew]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.year; // => 5779 +>date.year : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + date.month; // => 6 +>date.month : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + date.monthCode; // => 'M05L' +>date.monthCode : string +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + date.day; // => 18 +>date.day : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-000015-01-01[u-ca=gregory]" : "-000015-01-01[u-ca=gregory]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.era; +>date.era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 'bce' + date.eraYear; +>date.eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 16 + date.year; +>date.year : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + // => -15 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1]; // => 'THU' +>["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1] : string +> : ^^^^^^ +>["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"] : string[] +> : ^^^^^^^^ +>"MON" : "MON" +> : ^^^^^ +>"TUE" : "TUE" +> : ^^^^^ +>"WED" : "WED" +> : ^^^^^ +>"THU" : "THU" +> : ^^^^^ +>"FRI" : "FRI" +> : ^^^^^ +>"SAT" : "SAT" +> : ^^^^^ +>"SUN" : "SUN" +> : ^^^^^ +>date.dayOfWeek - 1 : number +> : ^^^^^^ +>date.dayOfWeek : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dayOfWeek : number +> : ^^^^^^ +>1 : 1 +> : ^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + // ISO ordinal date + console.log(date.year, date.dayOfYear); // => '2006 236' +>console.log(date.year, date.dayOfYear) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>date.year : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>date.dayOfYear : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dayOfYear : number +> : ^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2022-01-01"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2022-01-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2022-01-01" : "2022-01-01" +> : ^^^^^^^^^^^^ + + // ISO week date + console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek); // => '2021 52 6' +>console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>date.yearOfWeek : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>yearOfWeek : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date.weekOfYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>weekOfYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date.dayOfWeek : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dayOfWeek : number +> : ^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.daysInWeek; // => 7 +>date.daysInWeek : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>daysInWeek : number +> : ^^^^^^ +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ +>{} : {} +> : ^^ + + for (let month = 1; month <= 12; month++) { +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>month <= 12 : boolean +> : ^^^^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>month++ : number +> : ^^^^^^ +>month : number +> : ^^^^^^ + + const date = Temporal.Now.plainDateISO().with({ month }); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO().with({ month }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO().with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month } : { month: number; } +> : ^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date); +>monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date) : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[date.daysInMonth] : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date.daysInMonth : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>(monthsByDays[date.daysInMonth] || []).concat(date) : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[date.daysInMonth] || []).concat : { (...items: ConcatArray[]): Temporal.PlainDate[]; (...items: (Temporal.PlainDate | ConcatArray)[]): Temporal.PlainDate[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[date.daysInMonth] || []) : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[date.daysInMonth] || [] : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[date.daysInMonth] : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date.daysInMonth : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>[] : never[] +> : ^^^^^^^ +>concat : { (...items: ConcatArray[]): Temporal.PlainDate[]; (...items: (Temporal.PlainDate | ConcatArray)[]): Temporal.PlainDate[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ + } + + const strings = monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })); +>strings : string[] +> : ^^^^^^^^ +>monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })) : string[] +> : ^^^^^^^^ +>monthsByDays[30].map : (callbackfn: (value: Temporal.PlainDate, index: number, array: Temporal.PlainDate[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>monthsByDays[30] : Temporal.PlainDate[] +> : ^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>30 : 30 +> : ^^ +>map : (callbackfn: (value: Temporal.PlainDate, index: number, array: Temporal.PlainDate[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>date => date.toLocaleString("en", { month: "long" }) : (date: Temporal.PlainDate) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.toLocaleString("en", { month: "long" }) : string +> : ^^^^^^ +>date.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ month: "long" } : { month: "long"; } +> : ^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift(strings.pop()!) : number +> : ^^^^^^ +>strings.unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings.pop()! : string +> : ^^^^^^ +>strings.pop() : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>strings.pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + const format = new Intl.ListFormat("en"); +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>new Intl.ListFormat("en") : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>Intl.ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>Intl : typeof Intl +> : ^^^^^^^^^^^ +>ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>"en" : "en" +> : ^^^^ + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : string +> : ^^^^^^ +>`Thirty days hath ${format.format(strings)}` : string +> : ^^^^^^ +>format.format(strings) : string +> : ^^^^^^ +>format.format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>strings : string[] +> : ^^^^^^^^ + + console.log(poem); +>console.log(poem) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>poem : string +> : ^^^^^^ +} + +{ + const date = Temporal.Now.plainDateISO(); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const percent = date.dayOfYear / date.daysInYear; +>percent : number +> : ^^^^^^ +>date.dayOfYear / date.daysInYear : number +> : ^^^^^^ +>date.dayOfYear : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dayOfYear : number +> : ^^^^^^ +>date.daysInYear : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>daysInYear : number +> : ^^^^^^ + + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; +>`The year is ${percent.toLocaleString("en", { style: "percent" })} over!` : string +> : ^^^^^^ +>percent.toLocaleString("en", { style: "percent" }) : string +> : ^^^^^^ +>percent.toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>percent : number +> : ^^^^^^ +>toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ style: "percent" } : { style: "percent"; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>style : "percent" +> : ^^^^^^^^^ +>"percent" : "percent" +> : ^^^^^^^^^ + + // example output: "The year is 10% over!" +} + +{ + const date = Temporal.PlainDate.from("1900-01-01"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("1900-01-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1900-01-01" : "1900-01-01" +> : ^^^^^^^^^^^^ + + date.monthsInYear; // => 12 +>date.monthsInYear : number +> : ^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>monthsInYear : number +> : ^^^^^^ +} + +{ + // Is this year a leap year? + const date = Temporal.Now.plainDateISO(); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.inLeapYear; // example output: true +>date.inLeapYear : boolean +> : ^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>inLeapYear : boolean +> : ^^^^^^^ + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + date.with({ year: 2100 }).inLeapYear; // => false +>date.with({ year: 2100 }).inLeapYear : boolean +> : ^^^^^^^ +>date.with({ year: 2100 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2100 } : { year: number; } +> : ^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2100 : 2100 +> : ^^^^ +>inLeapYear : boolean +> : ^^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-01-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-01-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-01-24" : "2006-01-24" +> : ^^^^^^^^^^^^ + + // What's the first day of this month? + date.with({ day: 1 }); // => 2006-01-01 +>date.with({ day: 1 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: 1 } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ + + // What's the last day of the next month? + const nextMonthDate = date.add({ months: 1 }); +>nextMonthDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.add({ months: 1 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ + + nextMonthDate.with({ day: nextMonthDate.daysInMonth }); // => 2006-02-28 +>nextMonthDate.with({ day: nextMonthDate.daysInMonth }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>nextMonthDate.with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>nextMonthDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>with : (dateLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: nextMonthDate.daysInMonth } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>nextMonthDate.daysInMonth : number +> : ^^^^^^ +>nextMonthDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24[u-ca=japanese]"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24[u-ca=japanese]") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24[u-ca=japanese]" : "2006-08-24[u-ca=japanese]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.withCalendar("iso8601"); // => 2006-08-24 +>date.withCalendar("iso8601") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.withCalendar : (calendarLike: Temporal.CalendarLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>withCalendar : (calendarLike: Temporal.CalendarLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ +} + +{ + let date: Temporal.PlainDate; +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + date = Temporal.PlainDate.from("2006-08-24"); +>date = Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.add({ years: 20, months: 4 }); // => 2026-12-24 +>date.add({ years: 20, months: 4 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 20, months: 4 } : { years: number; months: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>20 : 20 +> : ^^ +>months : number +> : ^^^^^^ +>4 : 4 +> : ^ + + date = Temporal.PlainDate.from("2019-01-31"); +>date = Temporal.PlainDate.from("2019-01-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-01-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31" : "2019-01-31" +> : ^^^^^^^^^^^^ + + date.add({ months: 1 }); // => 2019-02-28 +>date.add({ months: 1 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ + + date.add({ months: 1 }, { overflow: "reject" }); // => throws +>date.add({ months: 1 }, { overflow: "reject" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ +} + +{ + let date: Temporal.PlainDate; +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + date = Temporal.PlainDate.from("2006-08-24"); +>date = Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.subtract({ years: 20, months: 4 }); // => 1986-04-24 +>date.subtract({ years: 20, months: 4 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 20, months: 4 } : { years: number; months: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>20 : 20 +> : ^^ +>months : number +> : ^^^^^^ +>4 : 4 +> : ^ + + date = Temporal.PlainDate.from("2019-03-31"); +>date = Temporal.PlainDate.from("2019-03-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-03-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-31" : "2019-03-31" +> : ^^^^^^^^^^^^ + + date.subtract({ months: 1 }); // => 2019-02-28 +>date.subtract({ months: 1 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ + + date.subtract({ months: 1 }, { overflow: "reject" }); // => throws +>date.subtract({ months: 1 }, { overflow: "reject" }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>date.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + const later = Temporal.PlainDate.from("2019-01-31"); +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-01-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31" : "2019-01-31" +> : ^^^^^^^^^^^^ + + earlier.until(later); // => P4543D +>earlier.until(later) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>earlier.until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ + + earlier.until(later, { largestUnit: "year" }); // => P12Y5M7D +>earlier.until(later, { largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>earlier.until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + later.until(earlier, { largestUnit: "year" }); // => -P12Y5M7D +>later.until(earlier, { largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>later.until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + // If you really need to calculate the difference between two Dates in + // hours, you can eliminate the ambiguity by explicitly choosing the + // point in time from which you want to reckon the difference. For + // example, using noon: + const noon = Temporal.PlainTime.from("12:00"); +>noon : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("12:00") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"12:00" : "12:00" +> : ^^^^^^^ + + earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }); +>earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>earlier.toPlainDateTime(noon).until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlier.toPlainDateTime(noon) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>earlier.toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>noon : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>later.toPlainDateTime(noon) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>later.toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>noon : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // => PT109032H + + const newyear = Temporal.PlainDate.from("2020-01-01"); +>newyear : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2020-01-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-01" : "2020-01-01" +> : ^^^^^^^^^^^^ + + newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }); +>newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>newyear.until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>newyear : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-15" : "2020-01-15" +> : ^^^^^^^^^^^^ +>{ smallestUnit: "month", roundingMode: "halfExpand" } : { smallestUnit: "month"; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => PT0S + newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }); +>newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>newyear.until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>newyear : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-16" : "2020-01-16" +> : ^^^^^^^^^^^^ +>{ smallestUnit: "month", roundingMode: "halfExpand" } : { smallestUnit: "month"; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => PT0S (mid-month dates rounded down to match `Temporal.PlainDateTime` behavior) + newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }); +>newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>newyear.until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>newyear : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-17" : "2020-01-17" +> : ^^^^^^^^^^^^ +>{ smallestUnit: "month", roundingMode: "halfExpand" } : { smallestUnit: "month"; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => PT1M +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + const later = Temporal.PlainDate.from("2019-01-31"); +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-01-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31" : "2019-01-31" +> : ^^^^^^^^^^^^ + + later.since(earlier); // => P4543D +>later.since(earlier) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>later.since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>later : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>earlier : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + const other = Temporal.PlainDate.from("2019-01-31"); +>other : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-01-31") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31" : "2019-01-31" +> : ^^^^^^^^^^^^ + + date.equals(other); // => false +>date.equals(other) : boolean +> : ^^^^^^^ +>date.equals : (other: Temporal.PlainDateLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainDateLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ + + date.equals(date); // => true +>date.equals(date) : boolean +> : ^^^^^^^ +>date.equals : (other: Temporal.PlainDateLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainDateLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.toString(); // => '2006-08-24' +>date.toString() : string +> : ^^^^^^ +>date.toString : (options?: Temporal.PlainDateToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.toLocaleString(); // example output: 8/24/2006 +>date.toLocaleString() : string +> : ^^^^^^ +>date.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + date.toLocaleString("de-DE"); // example output: '24.8.2006' +>date.toLocaleString("de-DE") : string +> : ^^^^^^ +>date.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + date.toLocaleString("de-DE", { weekday: "long" }); // => 'Donnerstag' +>date.toLocaleString("de-DE", { weekday: "long" }) : string +> : ^^^^^^ +>date.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ weekday: "long" } : { weekday: "long"; } +> : ^^^^^^^^^^^^^^^^^^^^ +>weekday : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ + + date.toLocaleString("en-US-u-nu-fullwide"); // => '8/24/2006' +>date.toLocaleString("en-US-u-nu-fullwide") : string +> : ^^^^^^ +>date.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en-US-u-nu-fullwide" : "en-US-u-nu-fullwide" +> : ^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const plainDate = Temporal.PlainDate.from("2006-08-24"); +>plainDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + const plainTime = Temporal.PlainTime.from("15:23:30.003"); +>plainTime : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("15:23:30.003") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"15:23:30.003" : "15:23:30.003" +> : ^^^^^^^^^^^^^^ + + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }); +>plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>plainDate.toZonedDateTime : { (timeZone: Temporal.TimeZoneLike): Temporal.ZonedDateTime; (item: Temporal.PlainDateToZonedDateTimeOptions): Temporal.ZonedDateTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>plainDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toZonedDateTime : { (timeZone: Temporal.TimeZoneLike): Temporal.ZonedDateTime; (item: Temporal.PlainDateToZonedDateTimeOptions): Temporal.ZonedDateTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "America/Los_Angeles", plainTime } : { timeZone: string; plainTime: Temporal.PlainTime; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"America/Los_Angeles" : "America/Los_Angeles" +> : ^^^^^^^^^^^^^^^^^^^^^ +>plainTime : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + // => 2006-08-24T15:23:30.003-07:00[America/Los_Angeles] + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }); +>plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>plainDate.toZonedDateTime : { (timeZone: Temporal.TimeZoneLike): Temporal.ZonedDateTime; (item: Temporal.PlainDateToZonedDateTimeOptions): Temporal.ZonedDateTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>plainDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toZonedDateTime : { (timeZone: Temporal.TimeZoneLike): Temporal.ZonedDateTime; (item: Temporal.PlainDateToZonedDateTimeOptions): Temporal.ZonedDateTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ timeZone: "America/Los_Angeles" } : { timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"America/Los_Angeles" : "America/Los_Angeles" +> : ^^^^^^^^^^^^^^^^^^^^^ + + // => 2006-08-24T00:00:00-07:00[America/Los_Angeles] +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + const time = Temporal.PlainTime.from("15:23:30.003"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("15:23:30.003") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"15:23:30.003" : "15:23:30.003" +> : ^^^^^^^^^^^^^^ + + date.toPlainDateTime(time); // => 2006-08-24T15:23:30.003 +>date.toPlainDateTime(time) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>date.toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + date.toPlainDateTime(); // => 2006-08-24T00:00:00 +>date.toPlainDateTime() : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>date.toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toPlainDateTime : (time?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + date.toPlainYearMonth(); // => 2006-08 +>date.toPlainYearMonth() : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>date.toPlainYearMonth : () => Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toPlainYearMonth : () => Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.toPlainMonthDay(); // => 08-24 +>date.toPlainMonthDay() : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>date.toPlainMonthDay : () => Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>toPlainMonthDay : () => Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + // Leet hour + const time = new Temporal.PlainTime(13, 37); // => 13:37:00 +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>new Temporal.PlainTime(13, 37) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>13 : 13 +> : ^^ +>37 : 37 +> : ^^ +} + +{ + let time: Temporal.PlainTime; +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + time = Temporal.PlainTime.from("03:24:30"); // => 03:24:30 +>time = Temporal.PlainTime.from("03:24:30") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("03:24:30") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"03:24:30" : "03:24:30" +> : ^^^^^^^^^^ + + time = Temporal.PlainTime.from("032430"); // => 03:24:30 +>time = Temporal.PlainTime.from("032430") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("032430") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"032430" : "032430" +> : ^^^^^^^^ + + time = Temporal.PlainTime.from("1995-12-07T03:24:30"); // => 03:24:30 +>time = Temporal.PlainTime.from("1995-12-07T03:24:30") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("1995-12-07T03:24:30") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30" : "1995-12-07T03:24:30" +> : ^^^^^^^^^^^^^^^^^^^^^ + + time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); +>time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30+01:00[Europe/Brussels]" : "1995-12-07T03:24:30+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 03:24:30 + // (same as above; time zone is ignored) + time === Temporal.PlainTime.from(time); // => false +>time === Temporal.PlainTime.from(time) : boolean +> : ^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from(time) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + time = Temporal.PlainTime.from({ +>time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9, millisecond: 68, microsecond: 346, nanosecond: 205, }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9, millisecond: 68, microsecond: 346, nanosecond: 205, }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 19, minute: 39, second: 9, millisecond: 68, microsecond: 346, nanosecond: 205, } : { hour: number; minute: number; second: number; millisecond: number; microsecond: number; nanosecond: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + hour: 19, +>hour : number +> : ^^^^^^ +>19 : 19 +> : ^^ + + minute: 39, +>minute : number +> : ^^^^^^ +>39 : 39 +> : ^^ + + second: 9, +>second : number +> : ^^^^^^ +>9 : 9 +> : ^ + + millisecond: 68, +>millisecond : number +> : ^^^^^^ +>68 : 68 +> : ^^ + + microsecond: 346, +>microsecond : number +> : ^^^^^^ +>346 : 346 +> : ^^^ + + nanosecond: 205, +>nanosecond : number +> : ^^^^^^ +>205 : 205 +> : ^^^ + + }); // => 19:39:09.068346205 + time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }); // => 19:39:09 +>time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 19, minute: 39, second: 9 } : { hour: number; minute: number; second: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>19 : 19 +> : ^^ +>minute : number +> : ^^^^^^ +>39 : 39 +> : ^^ +>second : number +> : ^^^^^^ +>9 : 9 +> : ^ + + time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")); +>time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2020-02-15T19:39:09") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-02-15T19:39:09" : "2020-02-15T19:39:09" +> : ^^^^^^^^^^^^^^^^^^^^^ + + // => 19:39:09 + // (same as above; Temporal.PlainDateTime has hour, minute, etc. properties) + + // Different overflow modes + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }); +>time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 15, minute: 60 } : { hour: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>minute : number +> : ^^^^^^ +>60 : 60 +> : ^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 15:59:00 + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }); +>time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 15, minute: -1 } : { hour: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>minute : number +> : ^^^^^^ +>-1 : -1 +> : ^^ +>1 : 1 +> : ^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 15:00:00 + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }); +>time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 15, minute: 60 } : { hour: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>minute : number +> : ^^^^^^ +>60 : 60 +> : ^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }); +>time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 15, minute: -1 } : { hour: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>minute : number +> : ^^^^^^ +>-1 : -1 +> : ^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws +} + +{ + const one = Temporal.PlainTime.from("03:24"); +>one : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("03:24") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"03:24" : "03:24" +> : ^^^^^^^ + + const two = Temporal.PlainTime.from("01:24"); +>two : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("01:24") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"01:24" : "01:24" +> : ^^^^^^^ + + const three = Temporal.PlainTime.from("01:24:05"); +>three : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("01:24:05") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"01:24:05" : "01:24:05" +> : ^^^^^^^^^^ + + const sorted = [one, two, three].sort(Temporal.PlainTime.compare); +>sorted : Temporal.PlainTime[] +> : ^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort(Temporal.PlainTime.compare) : Temporal.PlainTime[] +> : ^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort : (compareFn?: ((a: Temporal.PlainTime, b: Temporal.PlainTime) => number) | undefined) => Temporal.PlainTime[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three] : Temporal.PlainTime[] +> : ^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>two : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>three : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.PlainTime, b: Temporal.PlainTime) => number) | undefined) => Temporal.PlainTime[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.compare : (one: Temporal.PlainTimeLike, two: Temporal.PlainTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.PlainTimeLike, two: Temporal.PlainTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + sorted.join(" "); // => '01:24:00 01:24:05 03:24:00' +>sorted.join(" ") : string +> : ^^^^^^ +>sorted.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted : Temporal.PlainTime[] +> : ^^^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ +} + +{ + // Backward transitions will repeat clock times + const zdtDst = Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]"); +>zdtDst : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-11-01T01:45-07:00[America/Los_Angeles]" : "2020-11-01T01:45-07:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const zdtStandard = Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]"); +>zdtStandard : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-11-01T01:30-08:00[America/Los_Angeles]" : "2020-11-01T01:30-08:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // The "first" 1:45 (in Daylight Time) is earlier than the "second" 1:30 (in Standard Time) + Temporal.ZonedDateTime.compare(zdtDst, zdtStandard); // => -1 +>Temporal.ZonedDateTime.compare(zdtDst, zdtStandard) : number +> : ^^^^^^ +>Temporal.ZonedDateTime.compare : (one: Temporal.ZonedDateTimeLike, two: Temporal.ZonedDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.ZonedDateTimeLike, two: Temporal.ZonedDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdtDst : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtStandard : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + // 1:45 is later than 1:30 when looking at a wall clock + Temporal.PlainTime.compare(zdtDst, zdtStandard); // => 1 +>Temporal.PlainTime.compare(zdtDst, zdtStandard) : number +> : ^^^^^^ +>Temporal.PlainTime.compare : (one: Temporal.PlainTimeLike, two: Temporal.PlainTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.PlainTimeLike, two: Temporal.PlainTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdtDst : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtStandard : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + // Forward transitions will skip clock times. Skipped times will be disambiguated. + const zdtBase = Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]"); +>zdtBase : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-03-08[America/Los_Angeles]" : "2020-03-08[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const timeSkipped = Temporal.PlainTime.from("02:30"); +>timeSkipped : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("02:30") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"02:30" : "02:30" +> : ^^^^^^^ + + const timeValid = Temporal.PlainTime.from("03:30"); +>timeValid : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("03:30") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"03:30" : "03:30" +> : ^^^^^^^ + + const zdtSkipped = zdtBase.withPlainTime(timeSkipped); +>zdtSkipped : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtBase.withPlainTime(timeSkipped) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtBase.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdtBase : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeSkipped : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + const zdtValid = zdtBase.withPlainTime(timeValid); +>zdtValid : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtBase.withPlainTime(timeValid) : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtBase.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdtBase : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeValid : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + // The skipped time 2:30AM is disambiguated to 3:30AM, so the instants are equal + Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid); // => 0 +>Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid) : number +> : ^^^^^^ +>Temporal.ZonedDateTime.compare : (one: Temporal.ZonedDateTimeLike, two: Temporal.ZonedDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.ZonedDateTimeLike, two: Temporal.ZonedDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>zdtSkipped : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>zdtValid : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + // 2:30 is earlier than 3:30 on a wall clock + Temporal.PlainTime.compare(timeSkipped, timeValid); // => -1 +>Temporal.PlainTime.compare(timeSkipped, timeValid) : number +> : ^^^^^^ +>Temporal.PlainTime.compare : (one: Temporal.PlainTimeLike, two: Temporal.PlainTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.PlainTimeLike, two: Temporal.PlainTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeSkipped : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>timeValid : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.hour; // => 19 +>time.hour : number +> : ^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ + + time.minute; // => 39 +>time.minute : number +> : ^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>minute : number +> : ^^^^^^ + + time.second; // => 9 +>time.second : number +> : ^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>second : number +> : ^^^^^^ + + time.millisecond; // => 68 +>time.millisecond : number +> : ^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>millisecond : number +> : ^^^^^^ + + time.microsecond; // => 346 +>time.microsecond : number +> : ^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>microsecond : number +> : ^^^^^^ + + time.nanosecond; // => 205 +>time.nanosecond : number +> : ^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>nanosecond : number +> : ^^^^^^ +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + // What's the top of the next hour? + time.add({ hours: 1 }).with({ +>time.add({ hours: 1 }).with({ minute: 0, second: 0, millisecond: 0, microsecond: 0, nanosecond: 0, }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.add({ hours: 1 }).with : (timeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time.add({ hours: 1 }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.add : (duration: Temporal.DurationLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 1 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>1 : 1 +> : ^ +>with : (timeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minute: 0, second: 0, millisecond: 0, microsecond: 0, nanosecond: 0, } : { minute: number; second: number; millisecond: number; microsecond: number; nanosecond: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + minute: 0, +>minute : number +> : ^^^^^^ +>0 : 0 +> : ^ + + second: 0, +>second : number +> : ^^^^^^ +>0 : 0 +> : ^ + + millisecond: 0, +>millisecond : number +> : ^^^^^^ +>0 : 0 +> : ^ + + microsecond: 0, +>microsecond : number +> : ^^^^^^ +>0 : 0 +> : ^ + + nanosecond: 0, +>nanosecond : number +> : ^^^^^^ +>0 : 0 +> : ^ + + }); // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.add({ minutes: 5, nanoseconds: 800 }); // => 19:44:09.068347005 +>time.add({ minutes: 5, nanoseconds: 800 }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.add : (duration: Temporal.DurationLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 5, nanoseconds: 800 } : { minutes: number; nanoseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>5 : 5 +> : ^ +>nanoseconds : number +> : ^^^^^^ +>800 : 800 +> : ^^^ +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.subtract({ minutes: 5, nanoseconds: 800 }); // => 19:34:09.068345405 +>time.subtract({ minutes: 5, nanoseconds: 800 }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.subtract : (duration: Temporal.DurationLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 5, nanoseconds: 800 } : { minutes: number; nanoseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>5 : 5 +> : ^ +>nanoseconds : number +> : ^^^^^^ +>800 : 800 +> : ^^^ +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("20:13:20.971398099") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"20:13:20.971398099" : "20:13:20.971398099" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.until(Temporal.PlainTime.from("22:39:09.068346205")); // => PT2H25M48.096948106S +>time.until(Temporal.PlainTime.from("22:39:09.068346205")) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>time.until : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("22:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"22:39:09.068346205" : "22:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.until(Temporal.PlainTime.from("19:39:09.068346205")); // => -PT34M11.903051894S +>time.until(Temporal.PlainTime.from("19:39:09.068346205")) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>time.until : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + // Rounding, for example if you don't care about sub-seconds + time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }); +>time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>time.until : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("22:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"22:39:09.068346205" : "22:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "second" } : { smallestUnit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ + + // => PT2H25M48S +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("20:13:20.971398099") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"20:13:20.971398099" : "20:13:20.971398099" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.since(Temporal.PlainTime.from("19:39:09.068346205")); // => PT34M11.903051894S +>time.since(Temporal.PlainTime.from("19:39:09.068346205")) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>time.since : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.since(Temporal.PlainTime.from("22:39:09.068346205")); // => -PT2H25M48.096948106S +>time.since(Temporal.PlainTime.from("22:39:09.068346205")) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>time.since : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.PlainTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("22:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"22:39:09.068346205" : "22:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + // Round to a particular unit + time.round({ smallestUnit: "hour" }); // => 20:00:00 +>time.round({ smallestUnit: "hour" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.round : { (roundTo: Temporal.TimeUnit): Temporal.PlainTime; (roundTo: Temporal.RoundingOptions): Temporal.PlainTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: Temporal.TimeUnit): Temporal.PlainTime; (roundTo: Temporal.RoundingOptions): Temporal.PlainTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "hour" } : { smallestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // Round to an increment of a unit, e.g. half an hour: + time.round({ roundingIncrement: 30, smallestUnit: "minute" }); +>time.round({ roundingIncrement: 30, smallestUnit: "minute" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.round : { (roundTo: Temporal.TimeUnit): Temporal.PlainTime; (roundTo: Temporal.RoundingOptions): Temporal.PlainTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: Temporal.TimeUnit): Temporal.PlainTime; (roundTo: Temporal.RoundingOptions): Temporal.PlainTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 30, smallestUnit: "minute" } : { roundingIncrement: number; smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + // => 19:30:00 + // Round to the same increment but round up instead: + time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }); +>time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }) : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>time.round : { (roundTo: Temporal.TimeUnit): Temporal.PlainTime; (roundTo: Temporal.RoundingOptions): Temporal.PlainTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: Temporal.TimeUnit): Temporal.PlainTime; (roundTo: Temporal.RoundingOptions): Temporal.PlainTime; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" } : { roundingIncrement: number; smallestUnit: "minute"; roundingMode: "ceil"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ +>roundingMode : "ceil" +> : ^^^^^^ +>"ceil" : "ceil" +> : ^^^^^^ + + // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + const other = Temporal.PlainTime.from("20:13:20.971398099"); +>other : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("20:13:20.971398099") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"20:13:20.971398099" : "20:13:20.971398099" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.equals(other); // => false +>time.equals(other) : boolean +> : ^^^^^^^ +>time.equals : (other: Temporal.PlainTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + time.equals(time); // => true +>time.equals(time) : boolean +> : ^^^^^^^ +>time.equals : (other: Temporal.PlainTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.toString(); // => '19:39:09.068346205' +>time.toString() : string +> : ^^^^^^ +>time.toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + time.toString({ smallestUnit: "minute" }); // => '19:39' +>time.toString({ smallestUnit: "minute" }) : string +> : ^^^^^^ +>time.toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "minute" } : { smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09' +>time.toString({ fractionalSecondDigits: 0 }) : string +> : ^^^^^^ +>time.toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 0 } : { fractionalSecondDigits: 0; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 0 +> : ^ +>0 : 0 +> : ^ + + time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683' +>time.toString({ fractionalSecondDigits: 4 }) : string +> : ^^^^^^ +>time.toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 4 } : { fractionalSecondDigits: 4; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 4 +> : ^ +>4 : 4 +> : ^ + + time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }); +>time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }) : string +> : ^^^^^^ +>time.toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 5, roundingMode: "halfExpand" } : { fractionalSecondDigits: 5; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 5 +> : ^ +>5 : 5 +> : ^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => '19:39:09.06835' +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("19:39:09.068346205") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19:39:09.068346205" : "19:39:09.068346205" +> : ^^^^^^^^^^^^^^^^^^^^ + + time.toLocaleString(); // example output: '7:39:09 PM' +>time.toLocaleString() : string +> : ^^^^^^ +>time.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + time.toLocaleString("de-DE"); // example output: '19:39:09' +>time.toLocaleString("de-DE") : string +> : ^^^^^^ +>time.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }); // => '19:39:09' +>time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }) : string +> : ^^^^^^ +>time.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ timeZone: "Europe/Berlin" } : { timeZone: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"Europe/Berlin" : "Europe/Berlin" +> : ^^^^^^^^^^^^^^^ + + time.toLocaleString("en-US-u-nu-fullwide-hc-h24"); // => '19:39:09' +>time.toLocaleString("en-US-u-nu-fullwide-hc-h24") : string +> : ^^^^^^ +>time.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en-US-u-nu-fullwide-hc-h24" : "en-US-u-nu-fullwide-hc-h24" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + // Leet hour on pi day in 2020 + const datetime = new Temporal.PlainDateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37:00 +>datetime : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>new Temporal.PlainDateTime(2020, 3, 14, 13, 37) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>2020 : 2020 +> : ^^^^ +>3 : 3 +> : ^ +>14 : 14 +> : ^^ +>13 : 13 +> : ^^ +>37 : 37 +> : ^^ +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30"); +>dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30" : "1995-12-07T03:24:30" +> : ^^^^^^^^^^^^^^^^^^^^^ + + dt = Temporal.PlainDateTime.from("19951207T032430"); +>dt = Temporal.PlainDateTime.from("19951207T032430") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("19951207T032430") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"19951207T032430" : "19951207T032430" +> : ^^^^^^^^^^^^^^^^^ + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); +>dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30+01:00[Europe/Brussels]" : "1995-12-07T03:24:30+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 1995-12-07T03:24:30 + // same as above; time zone is ignored + dt === Temporal.PlainDateTime.from(dt); // => false +>dt === Temporal.PlainDateTime.from(dt) : boolean +> : ^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from(dt) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + dt = Temporal.PlainDateTime.from({ +>dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, } : { year: number; month: number; day: number; hour: number; minute: number; second: number; millisecond: number; microsecond: number; nanosecond: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + year: 1995, +>year : number +> : ^^^^^^ +>1995 : 1995 +> : ^^^^ + + month: 12, +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ + + day: 7, +>day : number +> : ^^^^^^ +>7 : 7 +> : ^ + + hour: 3, +>hour : number +> : ^^^^^^ +>3 : 3 +> : ^ + + minute: 24, +>minute : number +> : ^^^^^^ +>24 : 24 +> : ^^ + + second: 30, +>second : number +> : ^^^^^^ +>30 : 30 +> : ^^ + + millisecond: 0, +>millisecond : number +> : ^^^^^^ +>0 : 0 +> : ^ + + microsecond: 3, +>microsecond : number +> : ^^^^^^ +>3 : 3 +> : ^ + + nanosecond: 500, +>nanosecond : number +> : ^^^^^^ +>500 : 500 +> : ^^^ + + }); // => 1995-12-07T03:24:30.0000035 + dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }); // => 1995-12-07T00:00:00 +>dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 1995, month: 12, day: 7 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>1995 : 1995 +> : ^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>day : number +> : ^^^^^^ +>7 : 7 +> : ^ + + dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")); +>dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("1995-12-07T03:24:30") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30" : "1995-12-07T03:24:30" +> : ^^^^^^^^^^^^^^^^^^^^^ + + // => 1995-12-07T00:00:00 + // same as above; Temporal.PlainDate has year, month, and day properties + + dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }); +>dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" } : { year: number; month: number; day: number; hour: number; minute: number; second: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>5756 : 5756 +> : ^^^^ +>month : number +> : ^^^^^^ +>3 : 3 +> : ^ +>day : number +> : ^^^^^^ +>14 : 14 +> : ^^ +>hour : number +> : ^^^^^^ +>3 : 3 +> : ^ +>minute : number +> : ^^^^^^ +>24 : 24 +> : ^^ +>second : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>calendar : string +> : ^^^^^^ +>"hebrew" : "hebrew" +> : ^^^^^^^^ + + // => 1995-12-07T03:24:30[u-ca=hebrew] + + // Different overflow modes + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 13, day: 1 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-12-01T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 32 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>32 : 32 +> : ^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-01-31T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 1, hour: 25 } : { year: number; month: number; day: number; hour: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>hour : number +> : ^^^^^^ +>25 : 25 +> : ^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-01-01T23:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 1, minute: 60 } : { year: number; month: number; day: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>minute : number +> : ^^^^^^ +>60 : 60 +> : ^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-01-01T00:59:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 13, day: 1 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 32 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>32 : 32 +> : ^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 1, hour: 25 } : { year: number; month: number; day: number; hour: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>hour : number +> : ^^^^^^ +>25 : 25 +> : ^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }); +>dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 1, day: 1, minute: 60 } : { year: number; month: number; day: number; minute: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>minute : number +> : ^^^^^^ +>60 : 60 +> : ^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws +} + +{ + const one = Temporal.PlainDateTime.from("1995-12-07T03:24"); +>one : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24" : "1995-12-07T03:24" +> : ^^^^^^^^^^^^^^^^^^ + + const two = Temporal.PlainDateTime.from("1995-12-07T01:24"); +>two : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T01:24") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T01:24" : "1995-12-07T01:24" +> : ^^^^^^^^^^^^^^^^^^ + + const three = Temporal.PlainDateTime.from("2015-12-07T01:24"); +>three : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2015-12-07T01:24") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2015-12-07T01:24" : "2015-12-07T01:24" +> : ^^^^^^^^^^^^^^^^^^ + + const sorted = [one, two, three].sort(Temporal.PlainDateTime.compare); +>sorted : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort(Temporal.PlainDateTime.compare) : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort : (compareFn?: ((a: Temporal.PlainDateTime, b: Temporal.PlainDateTime) => number) | undefined) => Temporal.PlainDateTime[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three] : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>two : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>three : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.PlainDateTime, b: Temporal.PlainDateTime) => number) | undefined) => Temporal.PlainDateTime[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.compare : (one: Temporal.PlainDateTimeLike, two: Temporal.PlainDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.PlainDateTimeLike, two: Temporal.PlainDateTimeLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + sorted.join(" "); +>sorted.join(" ") : string +> : ^^^^^^ +>sorted.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ + + // => '1995-12-07T01:24:00 1995-12-07T03:24:00 2015-12-07T01:24:00' +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.year; // => 1995 +>dt.year : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + dt.month; // => 12 +>dt.month : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + dt.monthCode; // => 'M12' +>dt.monthCode : string +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + dt.day; // => 7 +>dt.day : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + dt.hour; // => 3 +>dt.hour : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ + + dt.minute; // => 24 +>dt.minute : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>minute : number +> : ^^^^^^ + + dt.second; // => 30 +>dt.second : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>second : number +> : ^^^^^^ + + dt.millisecond; // => 0 +>dt.millisecond : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>millisecond : number +> : ^^^^^^ + + dt.microsecond; // => 3 +>dt.microsecond : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>microsecond : number +> : ^^^^^^ + + dt.nanosecond; // => 500 +>dt.nanosecond : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>nanosecond : number +> : ^^^^^^ + + dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]"); +>dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-02-23T03:24:30.000003500[u-ca=hebrew]" : "2019-02-23T03:24:30.000003500[u-ca=hebrew]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.year; // => 5779 +>dt.year : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + dt.month; // => 6 +>dt.month : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + dt.monthCode; // => 'M05L' +>dt.monthCode : string +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + dt.day; // => 18 +>dt.day : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + dt.hour; // => 3 +>dt.hour : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ + + dt.minute; // => 24 +>dt.minute : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>minute : number +> : ^^^^^^ + + dt.second; // => 30 +>dt.second : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>second : number +> : ^^^^^^ + + dt.millisecond; // => 0 +>dt.millisecond : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>millisecond : number +> : ^^^^^^ + + dt.microsecond; // => 3 +>dt.microsecond : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>microsecond : number +> : ^^^^^^ + + dt.nanosecond; // => 500 +>dt.nanosecond : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>nanosecond : number +> : ^^^^^^ +} + +{ + const date = Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]"); +>date : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-000015-01-01T12:30[u-ca=gregory]" : "-000015-01-01T12:30[u-ca=gregory]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + date.era; +>date.era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 'bce' + date.eraYear; +>date.eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>date : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 16 + date.year; +>date.year : number +> : ^^^^^^ +>date : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + // => -15 +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1]; // => 'THU' +>["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1] : string +> : ^^^^^^ +>["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"] : string[] +> : ^^^^^^^^ +>"MON" : "MON" +> : ^^^^^ +>"TUE" : "TUE" +> : ^^^^^ +>"WED" : "WED" +> : ^^^^^ +>"THU" : "THU" +> : ^^^^^ +>"FRI" : "FRI" +> : ^^^^^ +>"SAT" : "SAT" +> : ^^^^^ +>"SUN" : "SUN" +> : ^^^^^ +>dt.dayOfWeek - 1 : number +> : ^^^^^^ +>dt.dayOfWeek : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfWeek : number +> : ^^^^^^ +>1 : 1 +> : ^ +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // ISO ordinal date + console.log(dt.year, dt.dayOfYear); // => '1995 341' +>console.log(dt.year, dt.dayOfYear) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>dt.year : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>dt.dayOfYear : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfYear : number +> : ^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2022-01-01T03:24:30.000003500" : "2022-01-01T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // ISO week date + console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek); // => '2021 52 6' +>console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>dt.yearOfWeek : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>yearOfWeek : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>dt.weekOfYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>weekOfYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>dt.dayOfWeek : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfWeek : number +> : ^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.daysInWeek; // => 7 +>dt.daysInWeek : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInWeek : number +> : ^^^^^^ +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ +>{} : {} +> : ^^ + + for (let month = 1; month <= 12; month++) { +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>month <= 12 : boolean +> : ^^^^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>month++ : number +> : ^^^^^^ +>month : number +> : ^^^^^^ + + const dt = Temporal.Now.plainDateTimeISO().with({ month }); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO().with({ month }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO().with : (dateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO() : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>with : (dateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month } : { month: number; } +> : ^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt); +>monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt) : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[dt.daysInMonth] : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt.daysInMonth : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>(monthsByDays[dt.daysInMonth] || []).concat(dt) : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[dt.daysInMonth] || []).concat : { (...items: ConcatArray[]): Temporal.PlainDateTime[]; (...items: (Temporal.PlainDateTime | ConcatArray)[]): Temporal.PlainDateTime[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[dt.daysInMonth] || []) : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[dt.daysInMonth] || [] : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[dt.daysInMonth] : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt.daysInMonth : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>[] : never[] +> : ^^^^^^^ +>concat : { (...items: ConcatArray[]): Temporal.PlainDateTime[]; (...items: (Temporal.PlainDateTime | ConcatArray)[]): Temporal.PlainDateTime[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + } + + const strings = monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })); +>strings : string[] +> : ^^^^^^^^ +>monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })) : string[] +> : ^^^^^^^^ +>monthsByDays[30].map : (callbackfn: (value: Temporal.PlainDateTime, index: number, array: Temporal.PlainDateTime[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>monthsByDays[30] : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>30 : 30 +> : ^^ +>map : (callbackfn: (value: Temporal.PlainDateTime, index: number, array: Temporal.PlainDateTime[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>dt => dt.toLocaleString("en", { month: "long" }) : (dt: Temporal.PlainDateTime) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.toLocaleString("en", { month: "long" }) : string +> : ^^^^^^ +>dt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ month: "long" } : { month: "long"; } +> : ^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift(strings.pop()!) : number +> : ^^^^^^ +>strings.unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings.pop()! : string +> : ^^^^^^ +>strings.pop() : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>strings.pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + const format = new Intl.ListFormat("en"); +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>new Intl.ListFormat("en") : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>Intl.ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>Intl : typeof Intl +> : ^^^^^^^^^^^ +>ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>"en" : "en" +> : ^^^^ + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : string +> : ^^^^^^ +>`Thirty days hath ${format.format(strings)}` : string +> : ^^^^^^ +>format.format(strings) : string +> : ^^^^^^ +>format.format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>strings : string[] +> : ^^^^^^^^ + + console.log(poem); +>console.log(poem) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>poem : string +> : ^^^^^^ +} + +{ + const dt = Temporal.Now.plainDateTimeISO(); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO() : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const percent = dt.dayOfYear / dt.daysInYear; +>percent : number +> : ^^^^^^ +>dt.dayOfYear / dt.daysInYear : number +> : ^^^^^^ +>dt.dayOfYear : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dayOfYear : number +> : ^^^^^^ +>dt.daysInYear : number +> : ^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>daysInYear : number +> : ^^^^^^ + + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; +>`The year is ${percent.toLocaleString("en", { style: "percent" })} over!` : string +> : ^^^^^^ +>percent.toLocaleString("en", { style: "percent" }) : string +> : ^^^^^^ +>percent.toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>percent : number +> : ^^^^^^ +>toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ style: "percent" } : { style: "percent"; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>style : "percent" +> : ^^^^^^^^^ +>"percent" : "percent" +> : ^^^^^^^^^ + + // example output: "The year is 10% over!" +} + +{ + const dt = Temporal.PlainDate.from("1900-01-01T12:00"); +>dt : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("1900-01-01T12:00") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1900-01-01T12:00" : "1900-01-01T12:00" +> : ^^^^^^^^^^^^^^^^^^ + + dt.monthsInYear; // => 12 +>dt.monthsInYear : number +> : ^^^^^^ +>dt : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>monthsInYear : number +> : ^^^^^^ +} + +{ + // Is this year a leap year? + const dt = Temporal.Now.plainDateTimeISO(); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO() : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.inLeapYear; // example output: true +>dt.inLeapYear : boolean +> : ^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>inLeapYear : boolean +> : ^^^^^^^ + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + dt.with({ year: 2100 }).inLeapYear; // => false +>dt.with({ year: 2100 }).inLeapYear : boolean +> : ^^^^^^^ +>dt.with({ year: 2100 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.with : (dateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>with : (dateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2100 } : { year: number; } +> : ^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2100 : 2100 +> : ^^^^ +>inLeapYear : boolean +> : ^^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035 +>dt.with({ year: 2015, second: 31 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.with : (dateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>with : (dateTimeLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2015, second: 31 } : { year: number; second: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2015 : 2015 +> : ^^^^ +>second : number +> : ^^^^^^ +>31 : 31 +> : ^^ +} + +{ + const dt = Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2015-12-07T03:24:30.000003500" : "2015-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00 +>dt.withPlainTime({ hour: 10 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hour: 10 } : { hour: number; } +> : ^^^^^^^^^^^^^^^^^ +>hour : number +> : ^^^^^^ +>10 : 10 +> : ^^ + + const time = Temporal.PlainTime.from("11:22"); +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from("11:22") : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime.from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainTime : Temporal.PlainTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"11:22" : "11:22" +> : ^^^^^^^ + + dt.withPlainTime(time); // => 2015-12-07T11:22:00 +>dt.withPlainTime(time) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>time : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ + + dt.withPlainTime("12:34"); // => 2015-12-07T12:34:00 +>dt.withPlainTime("12:34") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"12:34" : "12:34" +> : ^^^^^^^ + + // easier for chaining + dt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00 +>dt.add({ days: 2, hours: 22 }).withPlainTime("00:00") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.add({ days: 2, hours: 22 }).withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt.add({ days: 2, hours: 22 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 2, hours: 22 } : { days: number; hours: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>2 : 2 +> : ^ +>hours : number +> : ^^^^^^ +>22 : 22 +> : ^^ +>withPlainTime : (plainTime?: Temporal.PlainTimeLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"00:00" : "00:00" +> : ^^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500[u-ca=japanese]" : "1995-12-07T03:24:30.000003500[u-ca=japanese]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.withCalendar("iso8601"); // => 1995-12-07T03:24:30.0000035 +>dt.withCalendar("iso8601") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.withCalendar : (calendar: Temporal.CalendarLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>withCalendar : (calendar: Temporal.CalendarLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.add({ years: 20, months: 4, nanoseconds: 500 }); // => 2016-04-07T03:24:30.000004 +>dt.add({ years: 20, months: 4, nanoseconds: 500 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 20, months: 4, nanoseconds: 500 } : { years: number; months: number; nanoseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>20 : 20 +> : ^^ +>months : number +> : ^^^^^^ +>4 : 4 +> : ^ +>nanoseconds : number +> : ^^^^^^ +>500 : 500 +> : ^^^ + + dt = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt = Temporal.PlainDateTime.from("2019-01-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2019-01-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31T15:30" : "2019-01-31T15:30" +> : ^^^^^^^^^^^^^^^^^^ + + dt.add({ months: 1 }); // => 2019-02-28T15:30:00 +>dt.add({ months: 1 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ + + dt.add({ months: 1 }, { overflow: "reject" }); // => throws +>dt.add({ months: 1 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ +} + +{ + let dt: Temporal.PlainDateTime; +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.subtract({ years: 20, months: 4, nanoseconds: 500 }); // => 1975-08-07T03:24:30.000003 +>dt.subtract({ years: 20, months: 4, nanoseconds: 500 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 20, months: 4, nanoseconds: 500 } : { years: number; months: number; nanoseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>20 : 20 +> : ^^ +>months : number +> : ^^^^^^ +>4 : 4 +> : ^ +>nanoseconds : number +> : ^^^^^^ +>500 : 500 +> : ^^^ + + dt = Temporal.PlainDateTime.from("2019-03-31T15:30"); +>dt = Temporal.PlainDateTime.from("2019-03-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2019-03-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-03-31T15:30" : "2019-03-31T15:30" +> : ^^^^^^^^^^^^^^^^^^ + + dt.subtract({ months: 1 }); // => 2019-02-28T15:30:00 +>dt.subtract({ months: 1 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ + + dt.subtract({ months: 1 }, { overflow: "reject" }); // => throws +>dt.subtract({ months: 1 }, { overflow: "reject" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2019-01-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31T15:30" : "2019-01-31T15:30" +> : ^^^^^^^^^^^^^^^^^^ + + dt1.until(dt2); +>dt1.until(dt2) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>dt1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + // => P8456DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "year" }); +>dt1.until(dt2, { largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>dt1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + // => P23Y1M24DT12H5M29.9999965S + dt2.until(dt1, { largestUnit: "year" }); +>dt2.until(dt1, { largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>dt2.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + // => -P23Y1M24DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "nanosecond" }); +>dt1.until(dt2, { largestUnit: "nanosecond" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>dt1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "nanosecond" } : { largestUnit: "nanosecond"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "nanosecond" +> : ^^^^^^^^^^^^ +>"nanosecond" : "nanosecond" +> : ^^^^^^^^^^^^ + + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + dt1.until(dt2, { smallestUnit: "second" }); +>dt1.until(dt2, { smallestUnit: "second" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>dt1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "second" } : { smallestUnit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ + + // => P8456DT12H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })); +>jan1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>[1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })) : Temporal.PlainDateTime[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>[1, 2, 3].map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>[1, 2, 3] : number[] +> : ^^^^^^^^ +>1 : 1 +> : ^ +>2 : 2 +> : ^ +>3 : 3 +> : ^ +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 }) : (month: number) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>Temporal.PlainDateTime.from({ year: 2020, month, day: 1 }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2020, month, day: 1 } : { year: number; month: number; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2020 : 2020 +> : ^^^^ +>month : number +> : ^^^^^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ + + jan1.until(feb1); // => P31D +>jan1.until(feb1) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>jan1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>jan1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + jan1.until(feb1, { largestUnit: "month" }); // => P1M +>jan1.until(feb1, { largestUnit: "month" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>jan1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>jan1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "month" } : { largestUnit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + feb1.until(mar1); // => P29D +>feb1.until(mar1) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>feb1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + feb1.until(mar1, { largestUnit: "month" }); // => P1M +>feb1.until(mar1, { largestUnit: "month" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>feb1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>feb1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "month" } : { largestUnit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + jan1.until(mar1); // => P60D +>jan1.until(mar1) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>jan1.until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>jan1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>mar1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2019-01-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31T15:30" : "2019-01-31T15:30" +> : ^^^^^^^^^^^^^^^^^^ + + dt2.since(dt1); // => P8456DT12H5M29.9999965S +>dt2.since(dt1) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>dt2.since : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.PlainDateTimeLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // Round to a particular unit + dt.round({ smallestUnit: "hour" }); // => 1995-12-07T03:00:00 +>dt.round({ smallestUnit: "hour" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.PlainDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.PlainDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.PlainDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.PlainDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "hour" } : { smallestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // Round to an increment of a unit, e.g. half an hour: + dt.round({ roundingIncrement: 30, smallestUnit: "minute" }); +>dt.round({ roundingIncrement: 30, smallestUnit: "minute" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.PlainDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.PlainDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.PlainDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.PlainDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 30, smallestUnit: "minute" } : { roundingIncrement: number; smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + // => 1995-12-07T03:30:00 + // Round to the same increment but round down instead: + dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); +>dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.PlainDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.PlainDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.PlainDateTime; (roundTo: Temporal.RoundingOptions<"day" | "days" | Temporal.TimeUnit>): Temporal.PlainDateTime; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" } : { roundingIncrement: number; smallestUnit: "minute"; roundingMode: "floor"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>roundingIncrement : number +> : ^^^^^^ +>30 : 30 +> : ^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ +>roundingMode : "floor" +> : ^^^^^^^ +>"floor" : "floor" +> : ^^^^^^^ + + // => 1995-12-07T03:00:00 +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("2019-01-31T15:30") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-01-31T15:30" : "2019-01-31T15:30" +> : ^^^^^^^^^^^^^^^^^^ + + dt1.equals(dt2); // => false +>dt1.equals(dt2) : boolean +> : ^^^^^^^ +>dt1.equals : (other: Temporal.PlainDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt2 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + dt1.equals(dt1); // => true +>dt1.equals(dt1) : boolean +> : ^^^^^^^ +>dt1.equals : (other: Temporal.PlainDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainDateTimeLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt1 : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from({ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from({ year: 1999, month: 12, day: 31, hour: 23, minute: 59, second: 59, millisecond: 999, microsecond: 999, nanosecond: 999, }) : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 1999, month: 12, day: 31, hour: 23, minute: 59, second: 59, millisecond: 999, microsecond: 999, nanosecond: 999, } : { year: number; month: number; day: number; hour: number; minute: number; second: number; millisecond: number; microsecond: number; nanosecond: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + year: 1999, +>year : number +> : ^^^^^^ +>1999 : 1999 +> : ^^^^ + + month: 12, +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ + + day: 31, +>day : number +> : ^^^^^^ +>31 : 31 +> : ^^ + + hour: 23, +>hour : number +> : ^^^^^^ +>23 : 23 +> : ^^ + + minute: 59, +>minute : number +> : ^^^^^^ +>59 : 59 +> : ^^ + + second: 59, +>second : number +> : ^^^^^^ +>59 : 59 +> : ^^ + + millisecond: 999, +>millisecond : number +> : ^^^^^^ +>999 : 999 +> : ^^^ + + microsecond: 999, +>microsecond : number +> : ^^^^^^ +>999 : 999 +> : ^^^ + + nanosecond: 999, +>nanosecond : number +> : ^^^^^^ +>999 : 999 +> : ^^^ + + }); + dt.toString(); // => '1999-12-31T23:59:59.999999999' +>dt.toString() : string +> : ^^^^^^ +>dt.toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.toString({ smallestUnit: "minute" }); // => '1999-12-31T23:59' +>dt.toString({ smallestUnit: "minute" }) : string +> : ^^^^^^ +>dt.toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "minute" } : { smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + dt.toString({ fractionalSecondDigits: 0 }); // => '1999-12-31T23:59:59' +>dt.toString({ fractionalSecondDigits: 0 }) : string +> : ^^^^^^ +>dt.toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 0 } : { fractionalSecondDigits: 0; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 0 +> : ^ +>0 : 0 +> : ^ + + dt.toString({ fractionalSecondDigits: 4 }); // => '1999-12-31T23:59:59.9999' +>dt.toString({ fractionalSecondDigits: 4 }) : string +> : ^^^^^^ +>dt.toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 4 } : { fractionalSecondDigits: 4; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 4 +> : ^ +>4 : 4 +> : ^ + + dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); +>dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }) : string +> : ^^^^^^ +>dt.toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateTimeToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 8, roundingMode: "halfExpand" } : { fractionalSecondDigits: 8; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 8 +> : ^ +>8 : 8 +> : ^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => '2000-01-01T00:00:00.00000000' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.toLocaleString(); // example output: 1995-12-07, 3:24:30 a.m. +>dt.toLocaleString() : string +> : ^^^^^^ +>dt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + dt.toLocaleString("de-DE"); // example output: 7.12.1995, 03:24:30 +>dt.toLocaleString("de-DE") : string +> : ^^^^^^ +>dt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }); // => 'Donnerstag' +>dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }) : string +> : ^^^^^^ +>dt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ timeZone: "Europe/Berlin", weekday: "long" } : { timeZone: string; weekday: "long"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>timeZone : string +> : ^^^^^^ +>"Europe/Berlin" : "Europe/Berlin" +> : ^^^^^^^^^^^^^^^ +>weekday : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ + + dt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/7/1995, 3:24:30 AM' +>dt.toLocaleString("en-US-u-nu-fullwide-hc-h12") : string +> : ^^^^^^ +>dt.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en-US-u-nu-fullwide-hc-h12" : "en-US-u-nu-fullwide-hc-h12" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500") : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime.from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDateTime : Temporal.PlainDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateTimeLike, options?: Temporal.OverflowOptions) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1995-12-07T03:24:30.000003500" : "1995-12-07T03:24:30.000003500" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.toPlainDate(); // => 1995-12-07 +>dt.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.toPlainTime(); // => 03:24:30.0000035 +>dt.toPlainTime() : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>dt.toPlainTime : () => Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainTime : () => Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.toPlainDate().toPlainYearMonth(); // => 1995-12 +>dt.toPlainDate().toPlainYearMonth() : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate().toPlainYearMonth : () => Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainYearMonth : () => Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + dt.toPlainDate().toPlainMonthDay(); // => 12-07 +>dt.toPlainDate().toPlainMonthDay() : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate().toPlainMonthDay : () => Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>dt.toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>dt : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : () => Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainMonthDay : () => Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + // The June 2019 meeting + const ym = new Temporal.PlainYearMonth(2019, 6); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>new Temporal.PlainYearMonth(2019, 6) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>2019 : 2019 +> : ^^^^ +>6 : 6 +> : ^ + + // => 2019-06 +} + +{ + let ym: Temporal.PlainYearMonth; +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + ym = Temporal.PlainYearMonth.from("2019-06"); // => 2019-06 +>ym = Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym = Temporal.PlainYearMonth.from("2019-06-24"); // => 2019-06 +>ym = Temporal.PlainYearMonth.from("2019-06-24") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06-24") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06-24" : "2019-06-24" +> : ^^^^^^^^^^^^ + + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27"); // => 2019-06 +>ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06-24T15:43:27") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06-24T15:43:27" : "2019-06-24T15:43:27" +> : ^^^^^^^^^^^^^^^^^^^^^ + + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]"); +>ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06-24T15:43:27+01:00[Europe/Brussels]" : "2019-06-24T15:43:27+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 2019-06 + ym === Temporal.PlainYearMonth.from(ym); // => false +>ym === Temporal.PlainYearMonth.from(ym) : boolean +> : ^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from(ym) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ + + ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }); // => 2019-06 +>ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from({ year: 2019, month: 6 }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2019, month: 6 } : { year: number; month: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2019 : 2019 +> : ^^^^ +>month : number +> : ^^^^^^ +>6 : 6 +> : ^ + + ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")); +>ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2019-06-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06-24" : "2019-06-24" +> : ^^^^^^^^^^^^ + + // => 2019-06 + // (same as above; Temporal.PlainDate has year and month properties) + + // Different overflow modes + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }); +>ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 13 } : { year: number; month: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 2001-12 + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }); +>ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2001, month: 13 } : { year: number; month: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws +} + +{ + const one = Temporal.PlainYearMonth.from("2006-08"); +>one : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2006-08") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08" : "2006-08" +> : ^^^^^^^^^ + + const two = Temporal.PlainYearMonth.from("2015-07"); +>two : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2015-07") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2015-07" : "2015-07" +> : ^^^^^^^^^ + + const three = Temporal.PlainYearMonth.from("1930-02"); +>three : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("1930-02") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1930-02" : "1930-02" +> : ^^^^^^^^^ + + const sorted = [one, two, three].sort(Temporal.PlainYearMonth.compare); +>sorted : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort(Temporal.PlainYearMonth.compare) : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort : (compareFn?: ((a: Temporal.PlainYearMonth, b: Temporal.PlainYearMonth) => number) | undefined) => Temporal.PlainYearMonth[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three] : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>two : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>three : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.PlainYearMonth, b: Temporal.PlainYearMonth) => number) | undefined) => Temporal.PlainYearMonth[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.compare : (one: Temporal.PlainYearMonthLike, two: Temporal.PlainYearMonthLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.PlainYearMonthLike, two: Temporal.PlainYearMonthLike) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + sorted.join(" "); // => '1930-02 2006-08 2015-07' +>sorted.join(" ") : string +> : ^^^^^^ +>sorted.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ +} + +{ + let ym: Temporal.PlainYearMonth; +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + ym = Temporal.PlainYearMonth.from("2019-06"); +>ym = Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.year; // => 2019 +>ym.year : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + ym.month; // => 6 +>ym.month : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + ym.monthCode; // => 'M06' +>ym.monthCode : string +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]"); +>ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-02-23[u-ca=hebrew]" : "2019-02-23[u-ca=hebrew]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ + + ym.year; // => 5779 +>ym.year : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + ym.month; // => 6 +>ym.month : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ + + ym.monthCode; // => 'M05L' +>ym.monthCode : string +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-000015-01-01[u-ca=gregory]" : "-000015-01-01[u-ca=gregory]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ym.era; +>ym.era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>era : string | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 'bce' + ym.eraYear; +>ym.eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>eraYear : number | undefined +> : ^^^^^^^^^^^^^^^^^^ + + // => 16 + ym.year; +>ym.year : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ + + // => -15 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ +>{} : {} +> : ^^ + + for (let month = 1; month <= 12; month++) { +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>month <= 12 : boolean +> : ^^^^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +>month++ : number +> : ^^^^^^ +>month : number +> : ^^^^^^ + + const ym = Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2020, calendar: "iso8601", month } : { year: number; calendar: string; month: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2020 : 2020 +> : ^^^^ +>calendar : string +> : ^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ +>month : number +> : ^^^^^^ + + monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym); +>monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym) : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[ym.daysInMonth] : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym.daysInMonth : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>(monthsByDays[ym.daysInMonth] || []).concat(ym) : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[ym.daysInMonth] || []).concat : { (...items: ConcatArray[]): Temporal.PlainYearMonth[]; (...items: (Temporal.PlainYearMonth | ConcatArray)[]): Temporal.PlainYearMonth[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(monthsByDays[ym.daysInMonth] || []) : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[ym.daysInMonth] || [] : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays[ym.daysInMonth] : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym.daysInMonth : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>[] : never[] +> : ^^^^^^^ +>concat : { (...items: ConcatArray[]): Temporal.PlainYearMonth[]; (...items: (Temporal.PlainYearMonth | ConcatArray)[]): Temporal.PlainYearMonth[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ + } + + const strings = monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })); +>strings : string[] +> : ^^^^^^^^ +>monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })) : string[] +> : ^^^^^^^^ +>monthsByDays[30].map : (callbackfn: (value: Temporal.PlainYearMonth, index: number, array: Temporal.PlainYearMonth[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>monthsByDays[30] : Temporal.PlainYearMonth[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthsByDays : Record +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>30 : 30 +> : ^^ +>map : (callbackfn: (value: Temporal.PlainYearMonth, index: number, array: Temporal.PlainYearMonth[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ +>ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" }) : (ym: Temporal.PlainYearMonth) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym.toLocaleString("en", { month: "long", calendar: "iso8601" }) : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ month: "long", calendar: "iso8601" } : { month: "long"; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ +>calendar : string +> : ^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ + + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); +>strings.unshift(strings.pop()!) : number +> : ^^^^^^ +>strings.unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>unshift : (...items: string[]) => number +> : ^^^^ ^^^^^^^^^^^^^^^ +>strings.pop()! : string +> : ^^^^^^ +>strings.pop() : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>strings.pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>strings : string[] +> : ^^^^^^^^ +>pop : () => string | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + + const format = new Intl.ListFormat("en"); +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>new Intl.ListFormat("en") : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>Intl.ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>Intl : typeof Intl +> : ^^^^^^^^^^^ +>ListFormat : { new (locales?: Intl.LocalesArgument, options?: Intl.ListFormatOptions): Intl.ListFormat; prototype: Intl.ListFormat; supportedLocalesOf(locales: Intl.LocalesArgument, options?: Pick): Intl.UnicodeBCP47LocaleIdentifier[]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>"en" : "en" +> : ^^^^ + + const poem = `Thirty days hath ${format.format(strings)}`; +>poem : string +> : ^^^^^^ +>`Thirty days hath ${format.format(strings)}` : string +> : ^^^^^^ +>format.format(strings) : string +> : ^^^^^^ +>format.format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>format : Intl.ListFormat +> : ^^^^^^^^^^^^^^^ +>format : (list: Iterable) => string +> : ^ ^^ ^^^^^ +>strings : string[] +> : ^^^^^^^^ + + console.log(poem); +>console.log(poem) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>poem : string +> : ^^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2019, month: 6, calendar: "iso8601" } : { year: number; month: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2019 : 2019 +> : ^^^^ +>month : number +> : ^^^^^^ +>6 : 6 +> : ^ +>calendar : string +> : ^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ + + const percent = ym.daysInMonth / ym.daysInYear; +>percent : number +> : ^^^^^^ +>ym.daysInMonth / ym.daysInYear : number +> : ^^^^^^ +>ym.daysInMonth : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>daysInMonth : number +> : ^^^^^^ +>ym.daysInYear : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>daysInYear : number +> : ^^^^^^ + + `${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!`; +>`${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!` : string +> : ^^^^^^ +>ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" }) : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ month: "long", year: "numeric", calendar: "iso8601" } : { month: "long"; year: "numeric"; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ +>year : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ +>calendar : string +> : ^^^^^^ +>"iso8601" : "iso8601" +> : ^^^^^^^^^ +>percent.toLocaleString("en", { style: "percent" }) : string +> : ^^^^^^ +>percent.toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>percent : number +> : ^^^^^^ +>toLocaleString : (locales?: string | string[], options?: Intl.NumberFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en" : "en" +> : ^^^^ +>{ style: "percent" } : { style: "percent"; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>style : "percent" +> : ^^^^^^^^^ +>"percent" : "percent" +> : ^^^^^^^^^ + + // => 'June 2019 was 8% of the year!' +} + +{ + const ym = Temporal.PlainYearMonth.from("1900-01"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("1900-01") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"1900-01" : "1900-01" +> : ^^^^^^^^^ + + ym.monthsInYear; // => 12 +>ym.monthsInYear : number +> : ^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>monthsInYear : number +> : ^^^^^^ +} + +{ + // Was June 2019 in a leap year? + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.inLeapYear; // => false +>ym.inLeapYear : boolean +> : ^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>inLeapYear : boolean +> : ^^^^^^^ + + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + ym.with({ year: 2100 }).inLeapYear; // => false +>ym.with({ year: 2100 }).inLeapYear : boolean +> : ^^^^^^^ +>ym.with({ year: 2100 }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym.with : (yearMonthLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>with : (yearMonthLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2100 } : { year: number; } +> : ^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2100 : 2100 +> : ^^^^ +>inLeapYear : boolean +> : ^^^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + // Get December of that year + ym.with({ month: 12 }); // => 2019-12 +>ym.with({ month: 12 }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym.with : (yearMonthLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>with : (yearMonthLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 12 } : { month: number; } +> : ^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>12 : 12 +> : ^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.add({ years: 20, months: 4 }); // => 2039-10 +>ym.add({ years: 20, months: 4 }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 20, months: 4 } : { years: number; months: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>20 : 20 +> : ^^ +>months : number +> : ^^^^^^ +>4 : 4 +> : ^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.subtract({ years: 20, months: 4 }); // => 1999-02 +>ym.subtract({ years: 20, months: 4 }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>ym.subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 20, months: 4 } : { years: number; months: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>20 : 20 +> : ^^ +>months : number +> : ^^^^^^ +>4 : 4 +> : ^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2006-08"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2006-08") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08" : "2006-08" +> : ^^^^^^^^^ + + const other = Temporal.PlainYearMonth.from("2019-06"); +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.until(other); // => P12Y10M +>ym.until(other) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>ym.until : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ + + ym.until(other, { largestUnit: "month" }); // => P154M +>ym.until(other, { largestUnit: "month" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>ym.until : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "month" } : { largestUnit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + other.until(ym, { largestUnit: "month" }); // => -P154M +>other.until(ym, { largestUnit: "month" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>other.until : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>until : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "month" } : { largestUnit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + // If you really need to calculate the difference between two YearMonths + // in days, you can eliminate the ambiguity by explicitly choosing the + // day of the month (and if applicable, the time of that day) from which + // you want to reckon the difference. For example, using the first of + // the month to calculate a number of days: + ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }); // => P4687D +>ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>ym.toPlainDate({ day: 1 }).until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>ym.toPlainDate({ day: 1 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>ym.toPlainDate : (item: Temporal.PlainYearMonthToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : (item: Temporal.PlainYearMonthToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: 1 } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>until : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>other.toPlainDate({ day: 1 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>other.toPlainDate : (item: Temporal.PlainYearMonthToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : (item: Temporal.PlainYearMonthToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: 1 } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>{ largestUnit: "day" } : { largestUnit: "day"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "day" +> : ^^^^^ +>"day" : "day" +> : ^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + const other = Temporal.PlainYearMonth.from("2006-08"); +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2006-08") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08" : "2006-08" +> : ^^^^^^^^^ + + ym.since(other); // => P12Y10M +>ym.since(other) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>ym.since : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>since : (other: Temporal.PlainYearMonthLike, options?: Temporal.RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + const other = Temporal.PlainYearMonth.from("2006-08"); +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2006-08") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08" : "2006-08" +> : ^^^^^^^^^ + + ym.equals(other); // => false +>ym.equals(other) : boolean +> : ^^^^^^^ +>ym.equals : (other: Temporal.PlainYearMonthLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainYearMonthLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>other : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ + + ym.equals(ym); // => true +>ym.equals(ym) : boolean +> : ^^^^^^^ +>ym.equals : (other: Temporal.PlainYearMonthLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainYearMonthLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.toString(); // => '2019-06' +>ym.toString() : string +> : ^^^^^^ +>ym.toString : (options?: Temporal.PlainDateToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); +>calendar : string +> : ^^^^^^ +>new Intl.DateTimeFormat().resolvedOptions() : Intl.ResolvedDateTimeFormatOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>new Intl.DateTimeFormat().resolvedOptions : () => Intl.ResolvedDateTimeFormatOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>new Intl.DateTimeFormat() : Intl.DateTimeFormat +> : ^^^^^^^^^^^^^^^^^^^ +>Intl.DateTimeFormat : Intl.DateTimeFormatConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Intl : typeof Intl +> : ^^^^^^^^^^^ +>DateTimeFormat : Intl.DateTimeFormatConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>resolvedOptions : () => Intl.ResolvedDateTimeFormatOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }) : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ year: 2019, month: 6, calendar } : { year: number; month: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>year : number +> : ^^^^^^ +>2019 : 2019 +> : ^^^^ +>month : number +> : ^^^^^^ +>6 : 6 +> : ^ +>calendar : string +> : ^^^^^^ + + ym.toLocaleString(); // example output: '6/2019' +>ym.toLocaleString() : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + // Same as above, but explicitly specifying the calendar: + ym.toLocaleString(undefined, { calendar }); +>ym.toLocaleString(undefined, { calendar }) : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>undefined : undefined +> : ^^^^^^^^^ +>{ calendar } : { calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>calendar : string +> : ^^^^^^ + + ym.toLocaleString("de-DE", { calendar }); // example output: '6.2019' +>ym.toLocaleString("de-DE", { calendar }) : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ calendar } : { calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>calendar : string +> : ^^^^^^ + + ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }); // => 'Juni 2019' +>ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }) : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ month: "long", year: "numeric", calendar } : { month: "long"; year: "numeric"; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ +>year : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ +>calendar : string +> : ^^^^^^ + + ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '6/2019' +>ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`) : string +> : ^^^^^^ +>ym.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>`en-US-u-nu-fullwide-ca-${calendar}` : string +> : ^^^^^^ +>calendar : string +> : ^^^^^^ +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from("2019-06") : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth.from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainYearMonth : Temporal.PlainYearMonthConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainYearMonthLike, options?: Temporal.OverflowOptions) => Temporal.PlainYearMonth +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-06" : "2019-06" +> : ^^^^^^^^^ + + ym.toPlainDate({ day: 24 }); // => 2019-06-24 +>ym.toPlainDate({ day: 24 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>ym.toPlainDate : (item: Temporal.PlainYearMonthToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>ym : Temporal.PlainYearMonth +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : (item: Temporal.PlainYearMonthToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: 24 } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>24 : 24 +> : ^^ +} + +{ + let md: Temporal.PlainMonthDay; +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + // Pi day + md = new Temporal.PlainMonthDay(3, 14); // => 03-14 +>md = new Temporal.PlainMonthDay(3, 14) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>new Temporal.PlainMonthDay(3, 14) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>3 : 3 +> : ^ +>14 : 14 +> : ^^ + + // Leap day + md = new Temporal.PlainMonthDay(2, 29); // => 02-29 +>md = new Temporal.PlainMonthDay(2, 29) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>new Temporal.PlainMonthDay(2, 29) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>29 : 29 +> : ^^ +} + +{ + let md: Temporal.PlainMonthDay; +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + md = Temporal.PlainMonthDay.from("08-24"); // => 08-24 +>md = Temporal.PlainMonthDay.from("08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"08-24" : "08-24" +> : ^^^^^^^ + + md = Temporal.PlainMonthDay.from("0824"); // => 08-24 +>md = Temporal.PlainMonthDay.from("0824") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("0824") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"0824" : "0824" +> : ^^^^^^ + + md = Temporal.PlainMonthDay.from("2006-08-24"); // => 08-24 +>md = Temporal.PlainMonthDay.from("2006-08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("2006-08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27"); // => 08-24 +>md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("2006-08-24T15:43:27") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24T15:43:27" : "2006-08-24T15:43:27" +> : ^^^^^^^^^^^^^^^^^^^^^ + + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); +>md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24T15:43:27+01:00[Europe/Brussels]" : "2006-08-24T15:43:27+01:00[Europe/Brussels]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // => 08-24 + md === Temporal.PlainMonthDay.from(md); // => false +>md === Temporal.PlainMonthDay.from(md) : boolean +> : ^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from(md) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ + + md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }); // => 08-24 +>md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ monthCode: "M08", day: 24 } : { monthCode: string; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ +>"M08" : "M08" +> : ^^^^^ +>day : number +> : ^^^^^^ +>24 : 24 +> : ^^ + + md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")); +>md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2006-08-24") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2006-08-24" : "2006-08-24" +> : ^^^^^^^^^^^^ + + // => 08-24 + // (same as above; Temporal.PlainDate has month and day properties) + + // Different overflow modes + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }); +>md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 13, day: 1, year: 2000 } : { month: number; day: number; year: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>year : number +> : ^^^^^^ +>2000 : 2000 +> : ^^^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 12-01 + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }); +>md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 1, day: 32, year: 2000 } : { month: number; day: number; year: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>32 : 32 +> : ^^ +>year : number +> : ^^^^^^ +>2000 : 2000 +> : ^^^^ +>{ overflow: "constrain" } : { overflow: "constrain"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "constrain" +> : ^^^^^^^^^^^ +>"constrain" : "constrain" +> : ^^^^^^^^^^^ + + // => 01-31 + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }); +>md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 13, day: 1, year: 2000 } : { month: number; day: number; year: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>13 : 13 +> : ^^ +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ +>year : number +> : ^^^^^^ +>2000 : 2000 +> : ^^^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }); +>md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 1, day: 32, year: 2000 } : { month: number; day: number; year: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>1 : 1 +> : ^ +>day : number +> : ^^^^^^ +>32 : 32 +> : ^^ +>year : number +> : ^^^^^^ +>2000 : 2000 +> : ^^^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws + md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }); +>md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 2, day: 29, year: 2001 } : { month: number; day: number; year: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>2 : 2 +> : ^ +>day : number +> : ^^^^^^ +>29 : 29 +> : ^^ +>year : number +> : ^^^^^^ +>2001 : 2001 +> : ^^^^ +>{ overflow: "reject" } : { overflow: "reject"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>overflow : "reject" +> : ^^^^^^^^ +>"reject" : "reject" +> : ^^^^^^^^ + + // => throws (this year is not a leap year in the ISO 8601 calendar) + + // non-ISO calendars + md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }); +>md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ monthCode: "M05L", day: 15, calendar: "hebrew" } : { monthCode: string; day: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ +>"M05L" : "M05L" +> : ^^^^^^ +>day : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>calendar : string +> : ^^^^^^ +>"hebrew" : "hebrew" +> : ^^^^^^^^ + + // => 1970-02-21[u-ca=hebrew] + md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }); +>md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 6, day: 15, year: 5779, calendar: "hebrew" } : { month: number; day: number; year: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>6 : 6 +> : ^ +>day : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>year : number +> : ^^^^^^ +>5779 : 5779 +> : ^^^^ +>calendar : string +> : ^^^^^^ +>"hebrew" : "hebrew" +> : ^^^^^^^^ + + // => 1970-02-21[u-ca=hebrew] + /* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }); +>md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ month: 6, day: 15, calendar: "hebrew" } : { month: number; day: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : number +> : ^^^^^^ +>6 : 6 +> : ^ +>day : number +> : ^^^^^^ +>15 : 15 +> : ^^ +>calendar : string +> : ^^^^^^ +>"hebrew" : "hebrew" +> : ^^^^^^^^ + + // => throws (either year or monthCode is required) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); +>md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-02-20[u-ca=hebrew]" : "2019-02-20[u-ca=hebrew]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ + + md.monthCode; // => 'M05L' +>md.monthCode : string +> : ^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + md.day; // => 15 +>md.day : number +> : ^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + md.month; // undefined +>md.month : any +> : ^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>month : any +> : ^^^ + + // (month property is not present in this type; use monthCode instead) +} + +{ + let md: Temporal.PlainMonthDay; +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + md = Temporal.PlainMonthDay.from("08-24"); +>md = Temporal.PlainMonthDay.from("08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"08-24" : "08-24" +> : ^^^^^^^ + + md.monthCode; // => 'M08' +>md.monthCode : string +> : ^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + md.day; // => 24 +>md.day : number +> : ^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + md.month; // => undefined +>md.month : any +> : ^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>month : any +> : ^^^ + + // (no `month` property; use `monthCode` instead) + + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); +>md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2019-02-20[u-ca=hebrew]" : "2019-02-20[u-ca=hebrew]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ + + md.monthCode; // => 'M05L' +>md.monthCode : string +> : ^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ + + md.day; // => 15 +>md.day : number +> : ^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ + + md.month; // => undefined +>md.month : any +> : ^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>month : any +> : ^^^ + + // (no `month` property; use `monthCode` instead) +} + +{ + const md = Temporal.PlainMonthDay.from("11-15"); +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("11-15") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"11-15" : "11-15" +> : ^^^^^^^ + + // What's the last day of that month? + md.with({ day: 31 }); // => 11-30 +>md.with({ day: 31 }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>md.with : (monthDayLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>with : (monthDayLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: 31 } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>31 : 31 +> : ^^ + + Temporal.PlainMonthDay.from("02-01").with({ day: 31 }); // => 02-29 +>Temporal.PlainMonthDay.from("02-01").with({ day: 31 }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("02-01").with : (monthDayLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("02-01") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"02-01" : "02-01" +> : ^^^^^^^ +>with : (monthDayLike: Temporal.PartialTemporalLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ day: 31 } : { day: number; } +> : ^^^^^^^^^^^^^^^^ +>day : number +> : ^^^^^^ +>31 : 31 +> : ^^ +} + +{ + const md1 = Temporal.PlainMonthDay.from("02-28"); +>md1 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("02-28") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"02-28" : "02-28" +> : ^^^^^^^ + + const md2 = Temporal.PlainMonthDay.from("02-29"); +>md2 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("02-29") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"02-29" : "02-29" +> : ^^^^^^^ + + md1.equals(md2); // => false +>md1.equals(md2) : boolean +> : ^^^^^^^ +>md1.equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md1 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md2 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ + + md1.equals("02-29"); // => false +>md1.equals("02-29") : boolean +> : ^^^^^^^ +>md1.equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md1 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"02-29" : "02-29" +> : ^^^^^^^ + + md1.equals({ monthCode: "M02", day: 29 }); // => false +>md1.equals({ monthCode: "M02", day: 29 }) : boolean +> : ^^^^^^^ +>md1.equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md1 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ monthCode: "M02", day: 29 } : { monthCode: string; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ +>"M02" : "M02" +> : ^^^^^ +>day : number +> : ^^^^^^ +>29 : 29 +> : ^^ + + md2.equals(md2); // => true +>md2.equals(md2) : boolean +> : ^^^^^^^ +>md2.equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md2 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md2 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ + + md2.equals("02-29"); // => true +>md2.equals("02-29") : boolean +> : ^^^^^^^ +>md2.equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md2 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"02-29" : "02-29" +> : ^^^^^^^ + + md2.equals({ monthCode: "M02", day: 29 }); // => true +>md2.equals({ monthCode: "M02", day: 29 }) : boolean +> : ^^^^^^^ +>md2.equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md2 : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>equals : (other: Temporal.PlainMonthDayLike) => boolean +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ monthCode: "M02", day: 29 } : { monthCode: string; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ +>"M02" : "M02" +> : ^^^^^ +>day : number +> : ^^^^^^ +>29 : 29 +> : ^^ +} + +{ + const md = Temporal.PlainMonthDay.from("08-24"); +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from("08-24") : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"08-24" : "08-24" +> : ^^^^^^^ + + md.toString(); // => '08-24' +>md.toString() : string +> : ^^^^^^ +>md.toString : (options?: Temporal.PlainDateToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.PlainDateToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); +>calendar : string +> : ^^^^^^ +>new Intl.DateTimeFormat().resolvedOptions() : Intl.ResolvedDateTimeFormatOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>new Intl.DateTimeFormat().resolvedOptions : () => Intl.ResolvedDateTimeFormatOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>new Intl.DateTimeFormat() : Intl.DateTimeFormat +> : ^^^^^^^^^^^^^^^^^^^ +>Intl.DateTimeFormat : Intl.DateTimeFormatConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Intl : typeof Intl +> : ^^^^^^^^^^^ +>DateTimeFormat : Intl.DateTimeFormatConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>resolvedOptions : () => Intl.ResolvedDateTimeFormatOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }); +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ monthCode: "M08", day: 24, calendar } : { monthCode: string; day: number; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>monthCode : string +> : ^^^^^^ +>"M08" : "M08" +> : ^^^^^ +>day : number +> : ^^^^^^ +>24 : 24 +> : ^^ +>calendar : string +> : ^^^^^^ + + md.toLocaleString(); // example output: '8/24' +>md.toLocaleString() : string +> : ^^^^^^ +>md.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + // Same as above, but explicitly specifying the calendar: + md.toLocaleString(undefined, { calendar }); // example output: '8/24' +>md.toLocaleString(undefined, { calendar }) : string +> : ^^^^^^ +>md.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>undefined : undefined +> : ^^^^^^^^^ +>{ calendar } : { calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>calendar : string +> : ^^^^^^ + + md.toLocaleString("de-DE", { calendar }); // => '24.8.' +>md.toLocaleString("de-DE", { calendar }) : string +> : ^^^^^^ +>md.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ calendar } : { calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>calendar : string +> : ^^^^^^ + + md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }); // => '24. August' +>md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }) : string +> : ^^^^^^ +>md.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ +>{ month: "long", day: "numeric", calendar } : { month: "long"; day: "numeric"; calendar: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>month : "long" +> : ^^^^^^ +>"long" : "long" +> : ^^^^^^ +>day : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ +>calendar : string +> : ^^^^^^ + + md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '8/24' +>md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`) : string +> : ^^^^^^ +>md.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>`en-US-u-nu-fullwide-ca-${calendar}` : string +> : ^^^^^^ +>calendar : string +> : ^^^^^^ +} + +{ + const md = Temporal.PlainMonthDay.from({ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from({ calendar: "japanese", monthCode: "M01", day: 1, }) : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay.from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainMonthDay : Temporal.PlainMonthDayConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainMonthDayLike, options?: Temporal.OverflowOptions) => Temporal.PlainMonthDay +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ calendar: "japanese", monthCode: "M01", day: 1, } : { calendar: string; monthCode: string; day: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + calendar: "japanese", +>calendar : string +> : ^^^^^^ +>"japanese" : "japanese" +> : ^^^^^^^^^^ + + monthCode: "M01", +>monthCode : string +> : ^^^^^^ +>"M01" : "M01" +> : ^^^^^ + + day: 1, +>day : number +> : ^^^^^^ +>1 : 1 +> : ^ + + }); + + const date = md.toPlainDate({ era: "reiwa", eraYear: 2 }); // => 2020-01-01[u-ca=japanese] +>date : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>md.toPlainDate({ era: "reiwa", eraYear: 2 }) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>md.toPlainDate : (item: Temporal.PlainMonthDayToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>md : Temporal.PlainMonthDay +> : ^^^^^^^^^^^^^^^^^^^^^^ +>toPlainDate : (item: Temporal.PlainMonthDayToPlainDateOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ era: "reiwa", eraYear: 2 } : { era: string; eraYear: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>era : string +> : ^^^^^^ +>"reiwa" : "reiwa" +> : ^^^^^^^ +>eraYear : number +> : ^^^^^^ +>2 : 2 +> : ^ +} + +{ + new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); // => P1Y2M3W4DT5H6M7.987654321S +>new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>1 : 1 +> : ^ +>2 : 2 +> : ^ +>3 : 3 +> : ^ +>4 : 4 +> : ^ +>5 : 5 +> : ^ +>6 : 6 +> : ^ +>7 : 7 +> : ^ +>987 : 987 +> : ^^^ +>654 : 654 +> : ^^^ +>321 : 321 +> : ^^^ + + new Temporal.Duration(0, 0, 0, 40); // => P40D +>new Temporal.Duration(0, 0, 0, 40) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>0 : 0 +> : ^ +>0 : 0 +> : ^ +>0 : 0 +> : ^ +>40 : 40 +> : ^^ + + new Temporal.Duration(undefined, undefined, undefined, 40); // => P40D +>new Temporal.Duration(undefined, undefined, undefined, 40) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>undefined : undefined +> : ^^^^^^^^^ +>undefined : undefined +> : ^^^^^^^^^ +>undefined : undefined +> : ^^^^^^^^^ +>40 : 40 +> : ^^ + + new Temporal.Duration(); // => PT0S +>new Temporal.Duration() : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + let d: Temporal.Duration; +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + d = Temporal.Duration.from({ years: 1, days: 1 }); // => P1Y1D +>d = Temporal.Duration.from({ years: 1, days: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ years: 1, days: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 1, days: 1 } : { years: number; days: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>1 : 1 +> : ^ +>days : number +> : ^^^^^^ +>1 : 1 +> : ^ + + d = Temporal.Duration.from({ days: -2, hours: -12 }); // => -P2DT12H +>d = Temporal.Duration.from({ days: -2, hours: -12 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ days: -2, hours: -12 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: -2, hours: -12 } : { days: number; hours: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>-2 : -2 +> : ^^ +>2 : 2 +> : ^ +>hours : number +> : ^^^^^^ +>-12 : -12 +> : ^^^ +>12 : 12 +> : ^^ + + Temporal.Duration.from(d) === d; // => false +>Temporal.Duration.from(d) === d : boolean +> : ^^^^^^^ +>Temporal.Duration.from(d) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + d = Temporal.Duration.from("P1Y1D"); // => P1Y1D +>d = Temporal.Duration.from("P1Y1D") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("P1Y1D") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"P1Y1D" : "P1Y1D" +> : ^^^^^^^ + + d = Temporal.Duration.from("-P2DT12H"); // => -P2DT12H +>d = Temporal.Duration.from("-P2DT12H") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("-P2DT12H") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-P2DT12H" : "-P2DT12H" +> : ^^^^^^^^^^ + + d = Temporal.Duration.from("P0D"); // => PT0S +>d = Temporal.Duration.from("P0D") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("P0D") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"P0D" : "P0D" +> : ^^^^^ +} + +{ + const one = Temporal.Duration.from({ hours: 79, minutes: 10 }); +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 79, minutes: 10 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 79, minutes: 10 } : { hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>79 : 79 +> : ^^ +>minutes : number +> : ^^^^^^ +>10 : 10 +> : ^^ + + const two = Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }); +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 3, hours: 7, seconds: 630 } : { days: number; hours: number; seconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>3 : 3 +> : ^ +>hours : number +> : ^^^^^^ +>7 : 7 +> : ^ +>seconds : number +> : ^^^^^^ +>630 : 630 +> : ^^^ + + const three = Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }); +>three : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 3, hours: 6, minutes: 50 } : { days: number; hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>3 : 3 +> : ^ +>hours : number +> : ^^^^^^ +>6 : 6 +> : ^ +>minutes : number +> : ^^^^^^ +>50 : 50 +> : ^^ + + const sorted1 = [one, two, three].sort(Temporal.Duration.compare); +>sorted1 : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort(Temporal.Duration.compare) : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort : (compareFn?: ((a: Temporal.Duration, b: Temporal.Duration) => number) | undefined) => Temporal.Duration[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three] : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>three : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.Duration, b: Temporal.Duration) => number) | undefined) => Temporal.Duration[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration.compare : (one: Temporal.DurationLike, two: Temporal.DurationLike, options?: Temporal.DurationRelativeToOptions) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.DurationLike, two: Temporal.DurationLike, options?: Temporal.DurationRelativeToOptions) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + sorted1.join(" "); +>sorted1.join(" ") : string +> : ^^^^^^ +>sorted1.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted1 : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ + + // => 'P3DT6H50M PT79H10M P3DT7H630S' + + // Sorting relative to a date, taking DST changes into account: + const relativeTo = Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]"); +>relativeTo : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]") : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime.from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>ZonedDateTime : Temporal.ZonedDateTimeConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.ZonedDateTimeLike, options?: Temporal.ZonedDateTimeFromOptions) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-11-01T00:00-07:00[America/Los_Angeles]" : "2020-11-01T00:00-07:00[America/Los_Angeles]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const sorted2 = [one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })); +>sorted2 : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })) : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>[one, two, three].sort : (compareFn?: ((a: Temporal.Duration, b: Temporal.Duration) => number) | undefined) => Temporal.Duration[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[one, two, three] : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>three : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>sort : (compareFn?: ((a: Temporal.Duration, b: Temporal.Duration) => number) | undefined) => Temporal.Duration[] +> : ^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(one, two) => Temporal.Duration.compare(one, two, { relativeTo }) : (one: Temporal.Duration, two: Temporal.Duration) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.compare(one, two, { relativeTo }) : number +> : ^^^^^^ +>Temporal.Duration.compare : (one: Temporal.DurationLike, two: Temporal.DurationLike, options?: Temporal.DurationRelativeToOptions) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>compare : (one: Temporal.DurationLike, two: Temporal.DurationLike, options?: Temporal.DurationRelativeToOptions) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>{ relativeTo } : { relativeTo: Temporal.ZonedDateTime; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>relativeTo : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ + + sorted2.join(" "); +>sorted2.join(" ") : string +> : ^^^^^^ +>sorted2.join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>sorted2 : Temporal.Duration[] +> : ^^^^^^^^^^^^^^^^^^^ +>join : (separator?: string) => string +> : ^ ^^^ ^^^^^ +>" " : " " +> : ^^^ + + // => 'PT79H10M P3DT6H50M P3DT7H630S' +} + +{ + const d = Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S"); +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"P1Y2M3W4DT5H6M7.987654321S" : "P1Y2M3W4DT5H6M7.987654321S" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + d.years; // => 1 +>d.years : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ + + d.months; // => 2 +>d.months : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ + + d.weeks; // => 3 +>d.weeks : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>weeks : number +> : ^^^^^^ + + d.days; // => 4 +>d.days : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ + + d.hours; // => 5 +>d.hours : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ + + d.minutes; // => 6 +>d.minutes : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ + + d.seconds; // => 7 +>d.seconds : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>seconds : number +> : ^^^^^^ + + d.milliseconds; // => 987 +>d.milliseconds : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>milliseconds : number +> : ^^^^^^ + + d.microseconds; // => 654 +>d.microseconds : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>microseconds : number +> : ^^^^^^ + + d.nanoseconds; // => 321 +>d.nanoseconds : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>nanoseconds : number +> : ^^^^^^ +} + +{ + let d: Temporal.Duration; +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + d = Temporal.Duration.from("PT0S"); +>d = Temporal.Duration.from("PT0S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("PT0S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"PT0S" : "PT0S" +> : ^^^^^^ + + d.blank; // => true +>d.blank : boolean +> : ^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>blank : boolean +> : ^^^^^^^ + + d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }); +>d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 0, hours: 0, minutes: 0 } : { days: number; hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>0 : 0 +> : ^ +>hours : number +> : ^^^^^^ +>0 : 0 +> : ^ +>minutes : number +> : ^^^^^^ +>0 : 0 +> : ^ + + d.blank; // => true +>d.blank : boolean +> : ^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>blank : boolean +> : ^^^^^^^ +} + +{ + let duration: Temporal.Duration; +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }); +>duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 50, days: 50, hours: 50, minutes: 100 } : { months: number; days: number; hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>50 : 50 +> : ^^ +>days : number +> : ^^^^^^ +>50 : 50 +> : ^^ +>hours : number +> : ^^^^^^ +>50 : 50 +> : ^^ +>minutes : number +> : ^^^^^^ +>100 : 100 +> : ^^^ + + // Perform a balance operation using additional ISO 8601 calendar rules: + let { years, months } = duration; +>years : number +> : ^^^^^^ +>months : number +> : ^^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + years += Math.floor(months / 12); +>years += Math.floor(months / 12) : number +> : ^^^^^^ +>years : number +> : ^^^^^^ +>Math.floor(months / 12) : number +> : ^^^^^^ +>Math.floor : (x: number) => number +> : ^ ^^ ^^^^^ +>Math : Math +> : ^^^^ +>floor : (x: number) => number +> : ^ ^^ ^^^^^ +>months / 12 : number +> : ^^^^^^ +>months : number +> : ^^^^^^ +>12 : 12 +> : ^^ + + months %= 12; +>months %= 12 : number +> : ^^^^^^ +>months : number +> : ^^^^^^ +>12 : 12 +> : ^^ + + duration = duration.with({ years, months }); +>duration = duration.with({ years, months }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>duration.with({ years, months }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>duration.with : (durationLike: Temporal.PartialTemporalLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>duration : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>with : (durationLike: Temporal.PartialTemporalLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ years, months } : { years: number; months: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>months : number +> : ^^^^^^ + + // => P4Y2M50DT50H100M +} + +{ + const hour = Temporal.Duration.from("PT1H"); +>hour : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("PT1H") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"PT1H" : "PT1H" +> : ^^^^^^ + + hour.add({ minutes: 30 }); // => PT1H30M +>hour.add({ minutes: 30 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>hour.add : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hour : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>add : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 30 } : { minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>30 : 30 +> : ^^ + + // Examples of balancing: + const one = Temporal.Duration.from({ hours: 1, minutes: 30 }); +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 1, minutes: 30 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 1, minutes: 30 } : { hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>1 : 1 +> : ^ +>minutes : number +> : ^^^^^^ +>30 : 30 +> : ^^ + + const two = Temporal.Duration.from({ hours: 2, minutes: 45 }); +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 2, minutes: 45 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 2, minutes: 45 } : { hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>2 : 2 +> : ^ +>minutes : number +> : ^^^^^^ +>45 : 45 +> : ^^ + + const result = one.add(two); // => PT4H15M +>result : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>one.add(two) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>one.add : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>add : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + // Example of adding calendar units + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 16 }); +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ months: 1, days: 16 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1, days: 16 } : { months: number; days: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ +>days : number +> : ^^^^^^ +>16 : 16 +> : ^^ + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2000-12-01"); +>startDate1 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2000-12-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2000-12-01" : "2000-12-01" +> : ^^^^^^^^^^^^ + + startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) +>startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) .since(startDate1, { largestUnit: "months" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) .since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate1.add(oneAndAHalfMonth).add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate1.add(oneAndAHalfMonth) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate1.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate1 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + .since(startDate1, { largestUnit: "months" }); // => P3M4D +>since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate1 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "months" } : { largestUnit: "months"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "months" +> : ^^^^^^^^ +>"months" : "months" +> : ^^^^^^^^ + + const startDate2 = Temporal.PlainDate.from("2001-01-01"); +>startDate2 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2001-01-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2001-01-01" : "2001-01-01" +> : ^^^^^^^^^^^^ + + startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) +>startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) .since(startDate2, { largestUnit: "months" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) .since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate2.add(oneAndAHalfMonth).add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate2.add(oneAndAHalfMonth) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate2.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate2 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + .since(startDate2, { largestUnit: "months" }); // => P3M1D +>since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate2 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "months" } : { largestUnit: "months"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "months" +> : ^^^^^^^^ +>"months" : "months" +> : ^^^^^^^^ +} + +{ + const hourAndAHalf = Temporal.Duration.from("PT1H30M"); +>hourAndAHalf : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("PT1H30M") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"PT1H30M" : "PT1H30M" +> : ^^^^^^^^^ + + hourAndAHalf.subtract({ hours: 1 }); // => PT30M +>hourAndAHalf.subtract({ hours: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>hourAndAHalf.subtract : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hourAndAHalf : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>subtract : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 1 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>1 : 1 +> : ^ + + const one = Temporal.Duration.from({ minutes: 180 }); +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ minutes: 180 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 180 } : { minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>180 : 180 +> : ^^^ + + const two = Temporal.Duration.from({ seconds: 30 }); +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ seconds: 30 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ seconds: 30 } : { seconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^ +>seconds : number +> : ^^^^^^ +>30 : 30 +> : ^^ + + one.subtract(two); // => PT179M30S +>one.subtract(two) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>one.subtract : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>subtract : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + one.subtract(two).round({ largestUnit: "hour" }); // => PT2H59M30S +>one.subtract(two).round({ largestUnit: "hour" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>one.subtract(two).round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one.subtract(two) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>one.subtract : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>one : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>subtract : (other: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>two : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "hour" } : { largestUnit: "hour"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "hour" +> : ^^^^^^ +>"hour" : "hour" +> : ^^^^^^ + + // Example of subtracting calendar units; cannot be subtracted using + // subtract() because units need to be converted + const threeMonths = Temporal.Duration.from({ months: 3 }); +>threeMonths : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ months: 3 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 3 } : { months: number; } +> : ^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>3 : 3 +> : ^ + + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 15 }); +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ months: 1, days: 15 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 1, days: 15 } : { months: number; days: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>1 : 1 +> : ^ +>days : number +> : ^^^^^^ +>15 : 15 +> : ^^ + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2001-01-01"); +>startDate1 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2001-01-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2001-01-01" : "2001-01-01" +> : ^^^^^^^^^^^^ + + startDate1.add(threeMonths).subtract(oneAndAHalfMonth) +>startDate1.add(threeMonths).subtract(oneAndAHalfMonth) .since(startDate1, { largestUnit: "months" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startDate1.add(threeMonths).subtract(oneAndAHalfMonth) .since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate1.add(threeMonths).subtract(oneAndAHalfMonth) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate1.add(threeMonths).subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate1.add(threeMonths) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate1.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate1 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>threeMonths : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + .since(startDate1, { largestUnit: "months" }); // => P1M13D +>since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate1 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "months" } : { largestUnit: "months"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "months" +> : ^^^^^^^^ +>"months" : "months" +> : ^^^^^^^^ + + const startDate2 = Temporal.PlainDate.from("2001-02-01"); +>startDate2 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2001-02-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2001-02-01" : "2001-02-01" +> : ^^^^^^^^^^^^ + + startDate2.add(threeMonths).subtract(oneAndAHalfMonth) +>startDate2.add(threeMonths).subtract(oneAndAHalfMonth) .since(startDate2, { largestUnit: "months" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>startDate2.add(threeMonths).subtract(oneAndAHalfMonth) .since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate2.add(threeMonths).subtract(oneAndAHalfMonth) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate2.add(threeMonths).subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate2.add(threeMonths) : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>startDate2.add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>startDate2 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>add : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>threeMonths : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>subtract : (duration: Temporal.DurationLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>oneAndAHalfMonth : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ + + .since(startDate2, { largestUnit: "months" }); // => P1M16D +>since : (other: Temporal.PlainDateLike, options?: Temporal.RoundingOptionsWithLargestUnit) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>startDate2 : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "months" } : { largestUnit: "months"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "months" +> : ^^^^^^^^ +>"months" : "months" +> : ^^^^^^^^ +} + +{ + const d = Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S"); +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"P1Y2M3DT4H5M6.987654321S" : "P1Y2M3DT4H5M6.987654321S" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + d.sign; // 1 +>d.sign : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>sign : number +> : ^^^^^^ + + d.negated(); // -P1Y2M3DT4H5M6.987654321S +>d.negated() : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.negated : () => Temporal.Duration +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>negated : () => Temporal.Duration +> : ^^^^^^^^^^^^^^^^^^^^^^^ + + d.negated().sign; // -1 +>d.negated().sign : number +> : ^^^^^^ +>d.negated() : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.negated : () => Temporal.Duration +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>negated : () => Temporal.Duration +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>sign : number +> : ^^^^^^ +} + +{ + const d = Temporal.Duration.from("-PT8H30M"); +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("-PT8H30M") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"-PT8H30M" : "-PT8H30M" +> : ^^^^^^^^^^ + + d.abs(); // PT8H30M +>d.abs() : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.abs : () => Temporal.Duration +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>abs : () => Temporal.Duration +> : ^^^^^^^^^^^^^^^^^^^^^^^ +} + +{ + let d: Temporal.Duration; +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + // Balance a duration as far as possible without knowing a starting point + d = Temporal.Duration.from({ minutes: 130 }); +>d = Temporal.Duration.from({ minutes: 130 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ minutes: 130 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 130 } : { minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>130 : 130 +> : ^^^ + + d.round({ largestUnit: "day" }); // => PT2H10M +>d.round({ largestUnit: "day" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "day" } : { largestUnit: "day"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "day" +> : ^^^^^ +>"day" : "day" +> : ^^^^^ + + // Round to the nearest unit + d = Temporal.Duration.from({ minutes: 10, seconds: 52 }); +>d = Temporal.Duration.from({ minutes: 10, seconds: 52 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ minutes: 10, seconds: 52 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 10, seconds: 52 } : { minutes: number; seconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>10 : 10 +> : ^^ +>seconds : number +> : ^^^^^^ +>52 : 52 +> : ^^ + + d.round({ smallestUnit: "minute" }); // => PT11M +>d.round({ smallestUnit: "minute" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "minute" } : { smallestUnit: "minute"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + d.round({ smallestUnit: "minute", roundingMode: "trunc" }); // => PT10M +>d.round({ smallestUnit: "minute", roundingMode: "trunc" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "minute", roundingMode: "trunc" } : { smallestUnit: "minute"; roundingMode: "trunc"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ +>roundingMode : "trunc" +> : ^^^^^^^ +>"trunc" : "trunc" +> : ^^^^^^^ + + // How many seconds in a multi-unit duration? + d = Temporal.Duration.from("PT2H34M18S"); +>d = Temporal.Duration.from("PT2H34M18S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("PT2H34M18S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"PT2H34M18S" : "PT2H34M18S" +> : ^^^^^^^^^^^^ + + d.round({ largestUnit: "second" }).seconds; // => 9258 +>d.round({ largestUnit: "second" }).seconds : number +> : ^^^^^^ +>d.round({ largestUnit: "second" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "second" } : { largestUnit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ +>seconds : number +> : ^^^^^^ + + // Normalize, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); +>d = Temporal.Duration.from({ hours: 2756 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 2756 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 2756 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>2756 : 2756 +> : ^^^^ + + d.round({ +>d.round({ relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", largestUnit: "year", }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", largestUnit: "year", } : { relativeTo: string; largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", +>relativeTo : string +> : ^^^^^^ +>"2020-01-01T00:00+01:00[Europe/Rome]" : "2020-01-01T00:00+01:00[Europe/Rome]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + largestUnit: "year", +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + }); // => P114DT21H + // (one hour longer because DST skipped an hour) + d.round({ +>d.round({ relativeTo: "2020-01-01", largestUnit: "year", }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ relativeTo: "2020-01-01", largestUnit: "year", } : { relativeTo: string; largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + relativeTo: "2020-01-01", +>relativeTo : string +> : ^^^^^^ +>"2020-01-01" : "2020-01-01" +> : ^^^^^^^^^^^^ + + largestUnit: "year", +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + }); // => P114DT20H + // (one hour shorter if ignoring DST) + + // Normalize days into months or years + d = Temporal.Duration.from({ days: 190 }); +>d = Temporal.Duration.from({ days: 190 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ days: 190 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ days: 190 } : { days: number; } +> : ^^^^^^^^^^^^^^^^^ +>days : number +> : ^^^^^^ +>190 : 190 +> : ^^^ + + const refDate = Temporal.PlainDate.from("2020-01-01"); +>refDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from("2020-01-01") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate.from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>PlainDate : Temporal.PlainDateConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.PlainDateLike, options?: Temporal.OverflowOptions) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"2020-01-01" : "2020-01-01" +> : ^^^^^^^^^^^^ + + d.round({ relativeTo: refDate, largestUnit: "year" }); // => P6M8D +>d.round({ relativeTo: refDate, largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ relativeTo: refDate, largestUnit: "year" } : { relativeTo: Temporal.PlainDate; largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>relativeTo : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>refDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + // Same, but in a different calendar system + d.round({ +>d.round({ relativeTo: refDate.withCalendar("hebrew"), largestUnit: "year", }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ relativeTo: refDate.withCalendar("hebrew"), largestUnit: "year", } : { relativeTo: Temporal.PlainDate; largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + relativeTo: refDate.withCalendar("hebrew"), +>relativeTo : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>refDate.withCalendar("hebrew") : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>refDate.withCalendar : (calendarLike: Temporal.CalendarLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>refDate : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>withCalendar : (calendarLike: Temporal.CalendarLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"hebrew" : "hebrew" +> : ^^^^^^^^ + + largestUnit: "year", +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + }); // => P6M13D + + // Round a duration up to the next 5-minute billing period + d = Temporal.Duration.from({ minutes: 6 }); +>d = Temporal.Duration.from({ minutes: 6 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ minutes: 6 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ minutes: 6 } : { minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^ +>minutes : number +> : ^^^^^^ +>6 : 6 +> : ^ + + d.round({ +>d.round({ smallestUnit: "minute", roundingIncrement: 5, roundingMode: "ceil", }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "minute", roundingIncrement: 5, roundingMode: "ceil", } : { smallestUnit: "minute"; roundingIncrement: number; roundingMode: "ceil"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + smallestUnit: "minute", +>smallestUnit : "minute" +> : ^^^^^^^^ +>"minute" : "minute" +> : ^^^^^^^^ + + roundingIncrement: 5, +>roundingIncrement : number +> : ^^^^^^ +>5 : 5 +> : ^ + + roundingMode: "ceil", +>roundingMode : "ceil" +> : ^^^^^^ +>"ceil" : "ceil" +> : ^^^^^^ + + }); // => PT10M + + // How many full 3-month quarters of this year, are in this duration? + d = Temporal.Duration.from({ months: 10, days: 15 }); +>d = Temporal.Duration.from({ months: 10, days: 15 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ months: 10, days: 15 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ months: 10, days: 15 } : { months: number; days: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>10 : 10 +> : ^^ +>days : number +> : ^^^^^^ +>15 : 15 +> : ^^ + + d = d.round({ +>d = d.round({ smallestUnit: "month", roundingIncrement: 3, roundingMode: "trunc", relativeTo: Temporal.Now.plainDateISO(), }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round({ smallestUnit: "month", roundingIncrement: 3, roundingMode: "trunc", relativeTo: Temporal.Now.plainDateISO(), }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "month", roundingIncrement: 3, roundingMode: "trunc", relativeTo: Temporal.Now.plainDateISO(), } : { smallestUnit: "month"; roundingIncrement: number; roundingMode: "trunc"; relativeTo: Temporal.PlainDate; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + smallestUnit: "month", +>smallestUnit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + roundingIncrement: 3, +>roundingIncrement : number +> : ^^^^^^ +>3 : 3 +> : ^ + + roundingMode: "trunc", +>roundingMode : "trunc" +> : ^^^^^^^ +>"trunc" : "trunc" +> : ^^^^^^^ + + relativeTo: Temporal.Now.plainDateISO(), +>relativeTo : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + }); + const quarters = d.months / 3; +>quarters : number +> : ^^^^^^ +>d.months / 3 : number +> : ^^^^^^ +>d.months : number +> : ^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>months : number +> : ^^^^^^ +>3 : 3 +> : ^ + + quarters; // => 3 +>quarters : number +> : ^^^^^^ +} + +{ + let d: Temporal.Duration; +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + // How many seconds in 130 hours and 20 minutes? + d = Temporal.Duration.from({ hours: 130, minutes: 20 }); +>d = Temporal.Duration.from({ hours: 130, minutes: 20 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 130, minutes: 20 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 130, minutes: 20 } : { hours: number; minutes: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>130 : 130 +> : ^^^ +>minutes : number +> : ^^^^^^ +>20 : 20 +> : ^^ + + d.total({ unit: "second" }); // => 469200 +>d.total({ unit: "second" }) : number +> : ^^^^^^ +>d.total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>{ unit: "second" } : { unit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^ +>unit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ + + // How many 24-hour days is 123456789 seconds? + d = Temporal.Duration.from("PT123456789S"); +>d = Temporal.Duration.from("PT123456789S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("PT123456789S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"PT123456789S" : "PT123456789S" +> : ^^^^^^^^^^^^^^ + + d.total({ unit: "day" }); // 1428.8980208333332 +>d.total({ unit: "day" }) : number +> : ^^^^^^ +>d.total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>{ unit: "day" } : { unit: "day"; } +> : ^^^^^^^^^^^^^^^^ +>unit : "day" +> : ^^^^^ +>"day" : "day" +> : ^^^^^ + + // Find totals in months, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); +>d = Temporal.Duration.from({ hours: 2756 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ hours: 2756 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ hours: 2756 } : { hours: number; } +> : ^^^^^^^^^^^^^^^^^^ +>hours : number +> : ^^^^^^ +>2756 : 2756 +> : ^^^^ + + d.total({ +>d.total({ relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", unit: "month", }) : number +> : ^^^^^^ +>d.total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>{ relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", unit: "month", } : { relativeTo: string; unit: "month"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", +>relativeTo : string +> : ^^^^^^ +>"2020-01-01T00:00+01:00[Europe/Rome]" : "2020-01-01T00:00+01:00[Europe/Rome]" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + unit: "month", +>unit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + }); // => 3.7958333333333334 + d.total({ +>d.total({ unit: "month", relativeTo: "2020-01-01", }) : number +> : ^^^^^^ +>d.total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>total : { (totalOf: "day" | "days" | Temporal.TimeUnit): number; (totalOf: Temporal.DurationTotalOptions): number; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>{ unit: "month", relativeTo: "2020-01-01", } : { unit: "month"; relativeTo: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + unit: "month", +>unit : "month" +> : ^^^^^^^ +>"month" : "month" +> : ^^^^^^^ + + relativeTo: "2020-01-01", +>relativeTo : string +> : ^^^^^^ +>"2020-01-01" : "2020-01-01" +> : ^^^^^^^^^^^^ + + }); // => 3.7944444444444443 +} + +{ + let d: Temporal.Duration; +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal : any +> : ^^^ + + d = Temporal.Duration.from({ years: 1, days: 1 }); +>d = Temporal.Duration.from({ years: 1, days: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ years: 1, days: 1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: 1, days: 1 } : { years: number; days: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>1 : 1 +> : ^ +>days : number +> : ^^^^^^ +>1 : 1 +> : ^ + + d.toString(); // => P1Y1D +>d.toString() : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + d = Temporal.Duration.from({ years: -1, days: -1 }); +>d = Temporal.Duration.from({ years: -1, days: -1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ years: -1, days: -1 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ years: -1, days: -1 } : { years: number; days: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>years : number +> : ^^^^^^ +>-1 : -1 +> : ^^ +>1 : 1 +> : ^ +>days : number +> : ^^^^^^ +>-1 : -1 +> : ^^ +>1 : 1 +> : ^ + + d.toString(); // => -P1Y1D +>d.toString() : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + d = Temporal.Duration.from({ milliseconds: 1000 }); +>d = Temporal.Duration.from({ milliseconds: 1000 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ milliseconds: 1000 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ milliseconds: 1000 } : { milliseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>milliseconds : number +> : ^^^^^^ +>1000 : 1000 +> : ^^^^ + + d.toString(); // => PT1S +>d.toString() : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + // The output format always balances units under 1 s, even if the + // underlying Temporal.Duration object doesn't. + const nobal = Temporal.Duration.from({ milliseconds: 3500 }); +>nobal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from({ milliseconds: 3500 }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ milliseconds: 3500 } : { milliseconds: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>milliseconds : number +> : ^^^^^^ +>3500 : 3500 +> : ^^^^ + + console.log(`${nobal}`, nobal.seconds, nobal.milliseconds); // => 'PT3.5S 0 3500' +>console.log(`${nobal}`, nobal.seconds, nobal.milliseconds) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>`${nobal}` : string +> : ^^^^^^ +>nobal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>nobal.seconds : number +> : ^^^^^^ +>nobal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>seconds : number +> : ^^^^^^ +>nobal.milliseconds : number +> : ^^^^^^ +>nobal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>milliseconds : number +> : ^^^^^^ + + const bal = nobal.round({ largestUnit: "year" }); // balance through round +>bal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>nobal.round({ largestUnit: "year" }) : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>nobal.round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>nobal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>round : { (roundTo: "day" | "days" | Temporal.TimeUnit): Temporal.Duration; (roundTo: Temporal.DurationRoundingOptions): Temporal.Duration; } +> : ^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ largestUnit: "year" } : { largestUnit: "year"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>largestUnit : "year" +> : ^^^^^^ +>"year" : "year" +> : ^^^^^^ + + console.log(`${bal}`, bal.seconds, bal.milliseconds); // => 'PT3.5S 3 500' +>console.log(`${bal}`, bal.seconds, bal.milliseconds) : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>`${bal}` : string +> : ^^^^^^ +>bal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>bal.seconds : number +> : ^^^^^^ +>bal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>seconds : number +> : ^^^^^^ +>bal.milliseconds : number +> : ^^^^^^ +>bal : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>milliseconds : number +> : ^^^^^^ + + d = Temporal.Duration.from("PT59.999999999S"); +>d = Temporal.Duration.from("PT59.999999999S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("PT59.999999999S") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"PT59.999999999S" : "PT59.999999999S" +> : ^^^^^^^^^^^^^^^^^ + + d.toString({ smallestUnit: "second" }); // => PT59S +>d.toString({ smallestUnit: "second" }) : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ smallestUnit: "second" } : { smallestUnit: "second"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>smallestUnit : "second" +> : ^^^^^^^^ +>"second" : "second" +> : ^^^^^^^^ + + d.toString({ fractionalSecondDigits: 0 }); // => PT59S +>d.toString({ fractionalSecondDigits: 0 }) : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 0 } : { fractionalSecondDigits: 0; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 0 +> : ^ +>0 : 0 +> : ^ + + d.toString({ fractionalSecondDigits: 4 }); // => PT59.9999S +>d.toString({ fractionalSecondDigits: 4 }) : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 4 } : { fractionalSecondDigits: 4; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 4 +> : ^ +>4 : 4 +> : ^ + + d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); +>d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }) : string +> : ^^^^^^ +>d.toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toString : (options?: Temporal.DurationToStringOptions) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ fractionalSecondDigits: 8, roundingMode: "halfExpand" } : { fractionalSecondDigits: 8; roundingMode: "halfExpand"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fractionalSecondDigits : 8 +> : ^ +>8 : 8 +> : ^ +>roundingMode : "halfExpand" +> : ^^^^^^^^^^^^ +>"halfExpand" : "halfExpand" +> : ^^^^^^^^^^^^ + + // => PT60.00000000S +} + +{ + const d = Temporal.Duration.from("P1DT6H30M"); +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from("P1DT6H30M") : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>Temporal.Duration.from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Duration : Temporal.DurationConstructor +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>from : (item: Temporal.DurationLike) => Temporal.Duration +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>"P1DT6H30M" : "P1DT6H30M" +> : ^^^^^^^^^^^ + + d.toLocaleString(); // example output: '1 day 6 hours 30 minutes' +>d.toLocaleString() : string +> : ^^^^^^ +>d.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ + + d.toLocaleString("de-DE"); // example output: '1 Tag 6 Stunden 30 Minuten' +>d.toLocaleString("de-DE") : string +> : ^^^^^^ +>d.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"de-DE" : "de-DE" +> : ^^^^^^^ + + d.toLocaleString("en-US", { days: "short", hours: "numeric" }); // example output: '1 day 6 hours' +>d.toLocaleString("en-US", { days: "short", hours: "numeric" }) : string +> : ^^^^^^ +>d.toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>d : Temporal.Duration +> : ^^^^^^^^^^^^^^^^^ +>toLocaleString : (locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions) => string +> : ^ ^^^ ^^ ^^^ ^^^^^ +>"en-US" : "en-US" +> : ^^^^^^^ +>{ days: "short", hours: "numeric" } : { days: "short"; hours: "numeric"; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>days : "short" +> : ^^^^^^^ +>"short" : "short" +> : ^^^^^^^ +>hours : "numeric" +> : ^^^^^^^^^ +>"numeric" : "numeric" +> : ^^^^^^^^^ +} + +{ + Temporal.Now.instant(); // get the current system exact time +>Temporal.Now.instant() : Temporal.Instant +> : ^^^^^^^^^^^^^^^^ +>Temporal.Now.instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>instant : () => Temporal.Instant +> : ^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.Now.timeZoneId(); // get the current system time zone +>Temporal.Now.timeZoneId() : string +> : ^^^^^^ +>Temporal.Now.timeZoneId : () => string +> : ^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>timeZoneId : () => string +> : ^^^^^^ + + Temporal.Now.zonedDateTimeISO(); // get the current date and wall-clock time in the system time zone and ISO-8601 calendar +>Temporal.Now.zonedDateTimeISO() : Temporal.ZonedDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>zonedDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.ZonedDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.Now.plainDateISO(); // get the current date in the system time zone and ISO-8601 calendar +>Temporal.Now.plainDateISO() : Temporal.PlainDate +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDate +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.Now.plainTimeISO(); // get the current wall-clock time in the system time zone and ISO-8601 calendar +>Temporal.Now.plainTimeISO() : Temporal.PlainTime +> : ^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Temporal.Now.plainDateTimeISO(); // same as above, but return the DateTime in the ISO-8601 calendar +>Temporal.Now.plainDateTimeISO() : Temporal.PlainDateTime +> : ^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now.plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Temporal.Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>Temporal : typeof Temporal +> : ^^^^^^^^^^^^^^^ +>Now : typeof Temporal.Now +> : ^^^^^^^^^^^^^^^^^^^ +>plainDateTimeISO : (timeZone?: Temporal.TimeZoneLike) => Temporal.PlainDateTime +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + diff --git a/tests/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-set.js b/tests/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-set.js index c9af248f90400..0ddb5092b4e73 100644 --- a/tests/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-set.js @@ -117,7 +117,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set-even-if-FORCE_COLOR-is-set.js b/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set-even-if-FORCE_COLOR-is-set.js index 7a8f2c86f7a31..1a99e324df1a5 100644 --- a/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set-even-if-FORCE_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set-even-if-FORCE_COLOR-is-set.js @@ -117,7 +117,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js index 7a8f2c86f7a31..1a99e324df1a5 100644 --- a/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set.js @@ -117,7 +117,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/commandLine/help-all.js b/tests/baselines/reference/tsc/commandLine/help-all.js index 095773adbbe49..8cc8af02ae67d 100644 --- a/tests/baselines/reference/tsc/commandLine/help-all.js +++ b/tests/baselines/reference/tsc/commandLine/help-all.js @@ -577,7 +577,7 @@ default: react --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --libReplacement diff --git a/tests/baselines/reference/tsc/commandLine/help.js b/tests/baselines/reference/tsc/commandLine/help.js index 8893083b795f9..008df01a9e23e 100644 --- a/tests/baselines/reference/tsc/commandLine/help.js +++ b/tests/baselines/reference/tsc/commandLine/help.js @@ -116,7 +116,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index c9af248f90400..0ddb5092b4e73 100644 --- a/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -117,7 +117,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index c9af248f90400..0ddb5092b4e73 100644 --- a/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -117,7 +117,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js b/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js index e7e871b3dd898..2dbf30f84620b 100644 --- a/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js +++ b/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent-with---ignoreConfig.js @@ -126,7 +126,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js b/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js index 181be890c2204..3311854a36fb4 100644 --- a/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js +++ b/tests/baselines/reference/tsc/ignoreConfig/without-any-options-when-config-file-absent.js @@ -126,7 +126,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.typedarrays, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, es2024, es2025, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.arraybuffer, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.string, es2022.regexp, es2023.array, es2023.collection, es2023.intl, es2024.arraybuffer, es2024.collection, es2024.object/esnext.object, es2024.promise, es2024.regexp/esnext.regexp, es2024.sharedmemory, es2024.string/esnext.string, es2025.collection, es2025.float16/esnext.float16, es2025.intl, es2025.iterator/esnext.iterator, es2025.promise/esnext.promise, es2025.regexp, esnext.array, esnext.collection, esnext.date, esnext.decorators, esnext.disposable, esnext.error, esnext.intl, esnext.sharedmemory, esnext.temporal, esnext.typedarrays, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-Linux.js b/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-Linux.js index 28b1080ba5267..8cde4485d5553 100644 --- a/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-Linux.js +++ b/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-Linux.js @@ -172,12 +172,12 @@ Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/p //// [/home/src/tslibs/TS/Lib/lib.es2016.full.d.ts] *Lib* Inode:: 32 -//// [/home/src/projects/project/packages/package2/dist/index.js] Inode:: 128 +//// [/home/src/projects/project/packages/package2/dist/index.js] Inode:: 130 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] Inode:: 129 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] Inode:: 131 export {}; @@ -204,7 +204,7 @@ FsWatches:: /home/src/projects/project/packages/package2: *new* {"inode":11} /home/src/projects/project/packages/package2/dist: *new* - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: *new* {"inode":12} /home/src/projects/project/packages/package2/src: *new* @@ -254,20 +254,20 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 131 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 133 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 132 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 134 export type FooType = "foo"; export type BarType = "bar"; -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 133 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 135 {"root":["./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 134 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 136 { "root": [ "./src/index.ts" @@ -311,7 +311,7 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":130} + {"inode":132} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -319,7 +319,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -397,8 +397,8 @@ packages/package2/src/index.ts -//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 128 -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 129 +//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 130 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 131 PolledWatches:: /home/src/projects/project/packages/node_modules: @@ -418,9 +418,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: - {"inode":130} -/home/src/projects/project/packages/package1/dist/index.d.ts: *new* {"inode":132} +/home/src/projects/project/packages/package1/dist/index.d.ts: *new* + {"inode":134} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -428,7 +428,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -515,7 +515,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -529,9 +529,9 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/project/packages/package1/dist: - {"inode":130} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":132} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":134} Timeout callback:: count: 2 10: timerToUpdateProgram *new* @@ -617,8 +617,8 @@ Scheduling invalidateFailedLookup, Cancelled earlier one Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/project/node_modules/package1 :: WatchInfo: /home/src/projects/project/node_modules/package1 1 undefined Failed Lookup Locations -//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 128 -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 129 +//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 130 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 131 PolledWatches:: /home/src/projects/node_modules: *new* @@ -648,7 +648,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -826,14 +826,14 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 134 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 136 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 136 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 138 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 137 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 139 export type FooType = "foo"; export type BarType = "bar"; @@ -872,7 +872,7 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":135} + {"inode":137} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -880,7 +880,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -958,8 +958,8 @@ packages/package2/src/index.ts -//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 128 -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 129 +//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 130 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 131 PolledWatches:: /home/src/projects/project/packages/node_modules: @@ -979,9 +979,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: - {"inode":135} -/home/src/projects/project/packages/package1/dist/index.d.ts: *new* {"inode":137} +/home/src/projects/project/packages/package1/dist/index.d.ts: *new* + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -989,7 +989,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":127} + {"inode":129} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: diff --git a/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js b/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js index 577b04f75a5d8..2530319867f4f 100644 --- a/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js +++ b/tests/baselines/reference/tscWatch/symlinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js @@ -83,20 +83,20 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2016.full.d.ts] *Lib* Inode:: 32 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 128 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 130 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 129 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 131 export type FooType = "foo"; export type BarType = "bar"; -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 130 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 132 {"root":["./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 131 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 133 { "root": [ "./src/index.ts" @@ -168,12 +168,12 @@ DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/packages/packag Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/project/packages/package2 1 undefined Wild card directory -//// [/home/src/projects/project/packages/package2/dist/index.js] Inode:: 133 +//// [/home/src/projects/project/packages/package2/dist/index.js] Inode:: 135 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] Inode:: 134 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] Inode:: 136 export {}; @@ -192,9 +192,9 @@ FsWatches:: /home/src/projects/project/packages/package1: *new* {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":127} -/home/src/projects/project/packages/package1/dist/index.d.ts: *new* {"inode":129} +/home/src/projects/project/packages/package1/dist/index.d.ts: *new* + {"inode":131} /home/src/projects/project/packages/package1/package.json: *new* {"inode":7} /home/src/projects/project/packages/package1/src: *new* @@ -202,7 +202,7 @@ FsWatches:: /home/src/projects/project/packages/package2: *new* {"inode":11} /home/src/projects/project/packages/package2/dist: *new* - {"inode":132} + {"inode":134} /home/src/projects/project/packages/package2/package.json: *new* {"inode":12} /home/src/projects/project/packages/package2/src: *new* @@ -290,7 +290,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":132} + {"inode":134} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -304,9 +304,9 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/project/packages/package1/dist: - {"inode":127} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":129} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":131} Timeout callback:: count: 2 1: timerToUpdateProgram *new* @@ -395,8 +395,8 @@ Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/project/node_ sysLog:: Elapsed:: *ms:: onTimerToUpdateChildWatches:: 0 undefined -//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 134 +//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 136 PolledWatches:: /home/src/projects/node_modules: *new* @@ -426,7 +426,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":132} + {"inode":134} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -604,14 +604,14 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 130 -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 131 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 136 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 132 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 133 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 138 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 137 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 139 export type FooType = "foo"; export type BarType = "bar"; @@ -650,7 +650,7 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":135} + {"inode":137} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -658,7 +658,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":132} + {"inode":134} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: @@ -736,8 +736,8 @@ packages/package2/src/index.ts -//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 134 +//// [/home/src/projects/project/packages/package2/dist/index.js] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package2/dist/index.d.ts] file written with same contents Inode:: 136 PolledWatches:: /home/src/projects/project/packages/node_modules: @@ -757,9 +757,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: - {"inode":135} -/home/src/projects/project/packages/package1/dist/index.d.ts: *new* {"inode":137} +/home/src/projects/project/packages/package1/dist/index.d.ts: *new* + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -767,7 +767,7 @@ FsWatches:: /home/src/projects/project/packages/package2: {"inode":11} /home/src/projects/project/packages/package2/dist: - {"inode":132} + {"inode":134} /home/src/projects/project/packages/package2/package.json: {"inode":12} /home/src/projects/project/packages/package2/src: diff --git a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-Linux.js b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-Linux.js index a237e57f2bcb9..1362600b386f7 100644 --- a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-Linux.js +++ b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-Linux.js @@ -198,7 +198,7 @@ Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/b/2/b-imp //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 44 -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 151 export {}; @@ -276,7 +276,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 150 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 152 export const a = 10; @@ -294,7 +294,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 151 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 153 export const a = 10; @@ -312,26 +312,26 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 155 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 156 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 157 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 158 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 159 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 160 { "root": [ "./src/c.ts", @@ -341,28 +341,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 162 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 163 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 164 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 165 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 166 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 167 { "root": [ "./src/a.ts", @@ -407,7 +407,7 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":159} + {"inode":161} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -563,7 +563,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 151 PolledWatches:: /home/src/projects/a/1/a-impl/a/lib/node_modules: *new* @@ -583,11 +583,11 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib: - {"inode":159} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":161} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":163} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":165} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -609,11 +609,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":152} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":154} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":156} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":158} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: @@ -669,7 +669,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 166 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 168 export const a = 10; @@ -687,7 +687,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -811,17 +811,17 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib: - {"inode":159} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":161} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":163} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":165} /home/src/projects/c/3/c-impl/c/lib: - {"inode":152} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":154} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":156} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":158} Timeout callback:: count: 2 20: timerToUpdateProgram *new* @@ -925,7 +925,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 151 PolledWatches:: /home/src/projects/b/2/b-impl/node_modules: *new* @@ -1041,40 +1041,40 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 157 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 158 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 164 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 165 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 169 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 159 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 166 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 167 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 171 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 172 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 173 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 174 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 174 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 176 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 177 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 178 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 179 export * from './a'; export * from 'c'; @@ -1113,7 +1113,7 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":173} + {"inode":175} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1267,7 +1267,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 151 PolledWatches:: /home/src/projects/a/1/a-impl/a/lib/node_modules: *new* @@ -1287,11 +1287,11 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib: - {"inode":173} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":175} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":177} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":179} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1313,11 +1313,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":168} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":170} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":172} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":174} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-MacOs.js b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-MacOs.js index e2ba502b90dbd..bc71717296f34 100644 --- a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-MacOs.js +++ b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-MacOs.js @@ -198,7 +198,7 @@ Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/b/2/b-imp //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 44 -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 151 export {}; @@ -272,7 +272,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 150 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 152 export const a = 10; @@ -290,7 +290,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 151 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 153 export const a = 10; @@ -308,26 +308,26 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 155 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 156 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 157 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 158 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 159 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 160 { "root": [ "./src/c.ts", @@ -337,28 +337,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 162 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 163 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 164 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 165 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 166 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 167 { "root": [ "./src/a.ts", @@ -521,7 +521,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 151 PolledWatches:: /home/src/projects/a/1/a-impl/a/lib/node_modules: *new* @@ -541,9 +541,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":161} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":163} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":165} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -559,9 +559,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":154} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":156} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":158} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: @@ -629,7 +629,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 166 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 168 export const a = 10; @@ -658,7 +658,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -781,13 +781,13 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib/a.d.ts: - {"inode":161} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: {"inode":163} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":165} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":154} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":156} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":158} FsWatchesRecursive:: /home/src/projects/a: @@ -903,7 +903,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 151 PolledWatches:: /home/src/projects/b/2/b-impl/node_modules: *new* @@ -1000,40 +1000,40 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 157 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 158 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 164 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 165 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 169 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 159 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 166 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 167 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 171 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 172 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 173 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 174 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 174 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 176 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 177 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 178 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 179 export * from './a'; export * from 'c'; @@ -1182,7 +1182,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 149 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 151 PolledWatches:: /home/src/projects/a/1/a-impl/a/lib/node_modules: *new* @@ -1202,9 +1202,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":175} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":177} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":179} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -1220,9 +1220,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":170} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":172} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":174} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-Linux.js b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-Linux.js index 87f1ac66e56d4..66dfcfa4a3a35 100644 --- a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-Linux.js +++ b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-Linux.js @@ -92,26 +92,26 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 44 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 149 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 151 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 150 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 152 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 151 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 153 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 152 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 154 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 155 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 156 { "root": [ "./src/c.ts", @@ -121,28 +121,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 156 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 158 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 157 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 159 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 158 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 160 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 161 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 162 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 163 { "root": [ "./src/a.ts", @@ -274,7 +274,7 @@ DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/b/2/b-impl/b/src 1 unde Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/b/2/b-impl/b/src 1 undefined Wild card directory -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 163 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 165 export {}; @@ -287,11 +287,11 @@ FsWatches:: /home/src/projects: *new* {"inode":3} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":155} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":157} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":159} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":161} /home/src/projects/a/1/a-impl/a/node_modules: *new* {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: *new* @@ -313,11 +313,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: *new* {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":148} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":150} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":152} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":154} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: *new* @@ -366,7 +366,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 164 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 166 export const a = 10; @@ -384,7 +384,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 165 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 167 export const a = 10; @@ -402,7 +402,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 166 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 168 export const a = 10; @@ -420,7 +420,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -544,17 +544,17 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib: - {"inode":155} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":157} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":159} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":161} /home/src/projects/c/3/c-impl/c/lib: - {"inode":148} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":150} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":152} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":154} Timeout callback:: count: 2 11: timerToUpdateProgram *new* @@ -658,7 +658,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 163 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 165 PolledWatches:: /home/src/projects/b/2/b-impl/node_modules: *new* @@ -774,40 +774,40 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 153 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 154 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 160 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 161 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 169 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 156 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 163 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 171 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 172 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 173 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 174 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 174 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 176 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 177 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 178 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 179 export * from './a'; export * from 'c'; @@ -846,7 +846,7 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":173} + {"inode":175} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1000,7 +1000,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 163 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 165 PolledWatches:: /home/src/projects/a/1/a-impl/a/lib/node_modules: *new* @@ -1020,11 +1020,11 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib: - {"inode":173} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":175} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":177} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":179} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1046,11 +1046,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":168} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":170} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":172} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":174} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-MacOs.js b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-MacOs.js index 034d462080a70..264ad921e22c9 100644 --- a/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-MacOs.js +++ b/tests/baselines/reference/tscWatch/symlinks/packages-outside-project-folder-built-MacOs.js @@ -92,26 +92,26 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 44 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 149 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 151 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 150 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 152 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 151 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 153 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 152 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 154 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 155 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 156 { "root": [ "./src/c.ts", @@ -121,28 +121,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 156 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 158 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 157 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 159 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 158 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 160 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 161 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 162 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 163 { "root": [ "./src/a.ts", @@ -274,7 +274,7 @@ DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/b/2/b-impl/b/src 1 unde Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/b/2/b-impl/b/src 1 undefined Wild card directory -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 163 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] Inode:: 165 export {}; @@ -287,9 +287,9 @@ FsWatches:: /home/src/projects: *new* {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":157} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":159} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":161} /home/src/projects/a/1/a-impl/a/package.json: *new* {"inode":24} /home/src/projects/b: *new* @@ -305,9 +305,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: *new* {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":150} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":152} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":154} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: *new* @@ -368,7 +368,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 164 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 166 export const a = 10; @@ -397,7 +397,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 165 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 167 export const a = 10; @@ -426,7 +426,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in a Input:: -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 166 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 168 export const a = 10; @@ -455,7 +455,7 @@ exitCode:: ExitStatus.undefined Change:: change in unrelated folder in c Input:: -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -578,13 +578,13 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib/a.d.ts: - {"inode":157} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: {"inode":159} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":161} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":150} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":152} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":154} FsWatchesRecursive:: /home/src/projects/a: @@ -700,7 +700,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 163 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 165 PolledWatches:: /home/src/projects/b/2/b-impl/node_modules: *new* @@ -797,40 +797,40 @@ exitCode:: ExitStatus.undefined Change:: Build dependencies Input:: -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 153 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 154 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 160 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 161 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 169 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 156 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 163 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 171 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 172 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 173 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 174 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 174 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 176 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 177 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 178 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 179 export * from './a'; export * from 'c'; @@ -979,7 +979,7 @@ src/index.ts -//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 163 +//// [/home/src/projects/b/2/b-impl/b/lib/index.js] file written with same contents Inode:: 165 PolledWatches:: /home/src/projects/a/1/a-impl/a/lib/node_modules: *new* @@ -999,9 +999,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":175} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":177} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":179} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -1017,9 +1017,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":170} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":172} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":174} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true-useFsEventsOnParentDirectory.js b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true-useFsEventsOnParentDirectory.js index b40f0d431f94c..4a59c813f35e0 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true-useFsEventsOnParentDirectory.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true-useFsEventsOnParentDirectory.js @@ -43,7 +43,7 @@ FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts 25 //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 14 -//// [/user/username/projects/myproject/main.js] Inode:: 118 +//// [/user/username/projects/myproject/main.js] Inode:: 120 export const x = 10; @@ -120,7 +120,7 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/main.js] Inode:: 118 +//// [/user/username/projects/myproject/main.js] Inode:: 120 export const x = 10; export const y = 10; diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true.js b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true.js index 52b106026b575..e413b0271551b 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/fsWatchWithTimestamp-true.js @@ -43,7 +43,7 @@ FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts 25 //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 14 -//// [/user/username/projects/myproject/main.js] Inode:: 118 +//// [/user/username/projects/myproject/main.js] Inode:: 120 export const x = 10; @@ -122,7 +122,7 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/main.js] Inode:: 118 +//// [/user/username/projects/myproject/main.js] Inode:: 120 export const x = 10; export const y = 10; diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-event-ends-with-tilde.js b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-event-ends-with-tilde.js index 02f07f34dadd1..d8bf547e01751 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-event-ends-with-tilde.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-event-ends-with-tilde.js @@ -55,7 +55,7 @@ Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myprojec //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/user/username/projects/myproject/main.js] Inode:: 119 +//// [/user/username/projects/myproject/main.js] Inode:: 121 import { foo } from "./foo"; foo(); @@ -103,7 +103,7 @@ exitCode:: ExitStatus.undefined Change:: Replace file with rename event that introduces error Input:: -//// [/user/username/projects/myproject/foo.d.ts] Inode:: 120 +//// [/user/username/projects/myproject/foo.d.ts] Inode:: 122 export function foo2(): string; @@ -146,7 +146,7 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/foo.d.ts: - {"inode":120} *new* + {"inode":122} *new* /user/username/projects/myproject/main.ts: {"inode":5} /user/username/projects/myproject/tsconfig.json: @@ -187,7 +187,7 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 119 +//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 121 Timeout callback:: count: 0 9: timerToInvalidateFailedLookupResolutions *deleted* @@ -221,7 +221,7 @@ exitCode:: ExitStatus.undefined Change:: Replace file with rename event that fixes error Input:: -//// [/user/username/projects/myproject/foo.d.ts] Inode:: 121 +//// [/user/username/projects/myproject/foo.d.ts] Inode:: 123 export function foo(): string; @@ -264,7 +264,7 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/foo.d.ts: - {"inode":121} *new* + {"inode":123} *new* /user/username/projects/myproject/main.ts: {"inode":5} /user/username/projects/myproject/tsconfig.json: @@ -272,7 +272,7 @@ FsWatches:: FsWatches *deleted*:: /user/username/projects/myproject/foo.d.ts: - {"inode":120} + {"inode":122} Timeout callback:: count: 2 16: timerToUpdateProgram *new* @@ -295,7 +295,7 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 119 +//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 121 Timeout callback:: count: 0 18: timerToInvalidateFailedLookupResolutions *deleted* diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-occurs-when-file-is-still-on-the-disk.js b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-occurs-when-file-is-still-on-the-disk.js index a10a5b18e1818..26bfe72d9818a 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-occurs-when-file-is-still-on-the-disk.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode-when-rename-occurs-when-file-is-still-on-the-disk.js @@ -51,11 +51,11 @@ FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts 25 //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/user/username/projects/myproject/foo.js] Inode:: 119 +//// [/user/username/projects/myproject/foo.js] Inode:: 121 export {}; -//// [/user/username/projects/myproject/main.js] Inode:: 120 +//// [/user/username/projects/myproject/main.js] Inode:: 122 import { foo } from "./foo"; foo(); @@ -101,7 +101,7 @@ exitCode:: ExitStatus.undefined Change:: Introduce error such that when callback happens file is already appeared Input:: -//// [/user/username/projects/myproject/foo.ts] Inode:: 121 +//// [/user/username/projects/myproject/foo.ts] Inode:: 123 export declare function foo2(): string; @@ -155,8 +155,8 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/foo.js] file written with same contents Inode:: 119 -//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 120 +//// [/user/username/projects/myproject/foo.js] file written with same contents Inode:: 121 +//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 122 Program root files: [ @@ -187,7 +187,7 @@ exitCode:: ExitStatus.undefined Change:: Replace file with rename event that fixes error Input:: -//// [/user/username/projects/myproject/foo.ts] Inode:: 122 +//// [/user/username/projects/myproject/foo.ts] Inode:: 124 export declare function foo(): string; @@ -210,7 +210,7 @@ FsWatches:: /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":15} /user/username/projects/myproject/foo.ts: - {"inode":122} *new* + {"inode":124} *new* /user/username/projects/myproject/main.ts: {"inode":5} /user/username/projects/myproject/tsconfig.json: @@ -239,8 +239,8 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/foo.js] file written with same contents Inode:: 119 -//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 120 +//// [/user/username/projects/myproject/foo.js] file written with same contents Inode:: 121 +//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 122 Program root files: [ diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode.js b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode.js index 6203f9351cfaa..84c7a1eda7aa0 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/fsWatch/when-using-file-watching-thats-on-inode.js @@ -55,7 +55,7 @@ Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myprojec //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/user/username/projects/myproject/main.js] Inode:: 119 +//// [/user/username/projects/myproject/main.js] Inode:: 121 import { foo } from "./foo"; foo(); @@ -103,7 +103,7 @@ exitCode:: ExitStatus.undefined Change:: Replace file with rename event that introduces error Input:: -//// [/user/username/projects/myproject/foo.d.ts] Inode:: 120 +//// [/user/username/projects/myproject/foo.d.ts] Inode:: 122 export function foo2(): string; @@ -134,7 +134,7 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/foo.d.ts: - {"inode":120} *new* + {"inode":122} *new* /user/username/projects/myproject/main.ts: {"inode":5} /user/username/projects/myproject/tsconfig.json: @@ -175,7 +175,7 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 119 +//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 121 Timeout callback:: count: 0 5: timerToInvalidateFailedLookupResolutions *deleted* @@ -209,7 +209,7 @@ exitCode:: ExitStatus.undefined Change:: Replace file with rename event that fixes error Input:: -//// [/user/username/projects/myproject/foo.d.ts] Inode:: 121 +//// [/user/username/projects/myproject/foo.d.ts] Inode:: 123 export function foo(): string; @@ -240,7 +240,7 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/foo.d.ts: - {"inode":121} *new* + {"inode":123} *new* /user/username/projects/myproject/main.ts: {"inode":5} /user/username/projects/myproject/tsconfig.json: @@ -248,7 +248,7 @@ FsWatches:: FsWatches *deleted*:: /user/username/projects/myproject/foo.d.ts: - {"inode":120} + {"inode":122} Timeout callback:: count: 2 9: timerToUpdateProgram *new* @@ -271,7 +271,7 @@ CreatingProgramWith:: -//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 119 +//// [/user/username/projects/myproject/main.js] file written with same contents Inode:: 121 Timeout callback:: count: 0 10: timerToInvalidateFailedLookupResolutions *deleted* diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-dynamic-polling-when-renaming-file-in-subfolder.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-dynamic-polling-when-renaming-file-in-subfolder.js index 85301ce209701..200e7a5ec0f20 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-dynamic-polling-when-renaming-file-in-subfolder.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-dynamic-polling-when-renaming-file-in-subfolder.js @@ -36,7 +36,7 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/a/username/projects/project/src/file1.js] Inode:: 119 +//// [/a/username/projects/project/src/file1.js] Inode:: 121 "use strict"; @@ -77,7 +77,7 @@ exitCode:: ExitStatus.undefined Change:: Rename file1 to file2 Input:: -//// [/a/username/projects/project/src/file2.ts] Inode:: 120 +//// [/a/username/projects/project/src/file2.ts] Inode:: 122 //// [/a/username/projects/project/src/file1.ts] deleted @@ -131,7 +131,7 @@ Output:: -//// [/a/username/projects/project/src/file2.js] Inode:: 121 +//// [/a/username/projects/project/src/file2.js] Inode:: 123 "use strict"; @@ -142,7 +142,7 @@ PolledWatches *deleted*:: FsWatches:: /a/username/projects/project/src/file2.ts: *new* - {"inode":120} + {"inode":122} /a/username/projects/project/tsconfig.json: {"inode":7} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-watchDirectory-when-renaming-file-in-subfolder.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-watchDirectory-when-renaming-file-in-subfolder.js index 5cc0074937d49..5db652877bac4 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-watchDirectory-when-renaming-file-in-subfolder.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-non-recursive-watchDirectory-when-renaming-file-in-subfolder.js @@ -36,7 +36,7 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/a/username/projects/project/src/file1.js] Inode:: 119 +//// [/a/username/projects/project/src/file1.js] Inode:: 121 "use strict"; @@ -78,7 +78,7 @@ exitCode:: ExitStatus.undefined Change:: Rename file1 to file2 Input:: -//// [/a/username/projects/project/src/file2.ts] Inode:: 120 +//// [/a/username/projects/project/src/file2.ts] Inode:: 122 //// [/a/username/projects/project/src/file1.ts] deleted @@ -121,7 +121,7 @@ Output:: -//// [/a/username/projects/project/src/file2.js] Inode:: 121 +//// [/a/username/projects/project/src/file2.js] Inode:: 123 "use strict"; @@ -136,7 +136,7 @@ FsWatches:: /a/username/projects/project/src: {"inode":5} /a/username/projects/project/src/file2.ts: *new* - {"inode":120} + {"inode":122} /a/username/projects/project/tsconfig.json: {"inode":7} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-watchFile-when-renaming-file-in-subfolder.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-watchFile-when-renaming-file-in-subfolder.js index 3f1d294c67064..48dff58b26ea9 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-watchFile-when-renaming-file-in-subfolder.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/uses-watchFile-when-renaming-file-in-subfolder.js @@ -36,7 +36,7 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/a/username/projects/project/src/file1.js] Inode:: 119 +//// [/a/username/projects/project/src/file1.js] Inode:: 121 "use strict"; @@ -80,7 +80,7 @@ exitCode:: ExitStatus.undefined Change:: Rename file1 to file2 Input:: -//// [/a/username/projects/project/src/file2.ts] Inode:: 120 +//// [/a/username/projects/project/src/file2.ts] Inode:: 122 //// [/a/username/projects/project/src/file1.ts] deleted @@ -123,7 +123,7 @@ Output:: -//// [/a/username/projects/project/src/file2.js] Inode:: 121 +//// [/a/username/projects/project/src/file2.js] Inode:: 123 "use strict"; @@ -140,7 +140,7 @@ PolledWatches *deleted*:: FsWatches:: /a/username/projects/project/src/file2.ts: *new* - {"inode":120} + {"inode":122} /a/username/projects/project/tsconfig.json: {"inode":7} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders-with-synchronousWatchDirectory.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders-with-synchronousWatchDirectory.js index 14c83ab7da167..663f48a14a556 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders-with-synchronousWatchDirectory.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders-with-synchronousWatchDirectory.js @@ -108,7 +108,7 @@ Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/user/projects/myprojec //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 25 -//// [/home/user/projects/myproject/src/file.js] Inode:: 129 +//// [/home/user/projects/myproject/src/file.js] Inode:: 131 export {}; @@ -324,7 +324,7 @@ FileWatcher:: Close:: WatchInfo: /home/user/projects/package.json 2000 {"synchro -//// [/home/user/projects/myproject/src/file.js] file written with same contents Inode:: 129 +//// [/home/user/projects/myproject/src/file.js] file written with same contents Inode:: 131 PolledWatches:: /home/user/projects/node_modules: *new* diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders.js index 8c0c6fdbdf58d..ee1ebfac96b49 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/when-there-are-symlinks-to-folders-in-recursive-folders.js @@ -103,7 +103,7 @@ Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/user/projects/myprojec //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 25 -//// [/home/user/projects/myproject/src/file.js] Inode:: 129 +//// [/home/user/projects/myproject/src/file.js] Inode:: 131 export {}; @@ -330,7 +330,7 @@ Elapsed:: *ms DirectoryWatcher:: Triggered with /home/user/projects/myproject/no sysLog:: Elapsed:: *ms:: onTimerToUpdateChildWatches:: 0 undefined -//// [/home/user/projects/myproject/src/file.js] file written with same contents Inode:: 129 +//// [/home/user/projects/myproject/src/file.js] file written with same contents Inode:: 131 PolledWatches:: /home/user/projects/node_modules: *new* diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-renaming-a-file.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-renaming-a-file.js index f1ea10f837e7a..dc501cbb33162 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-renaming-a-file.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-renaming-a-file.js @@ -45,11 +45,11 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 16 -//// [/user/username/projects/myproject/dist/src/file2.js] Inode:: 122 +//// [/user/username/projects/myproject/dist/src/file2.js] Inode:: 124 export const x = 10; -//// [/user/username/projects/myproject/dist/src/file1.js] Inode:: 123 +//// [/user/username/projects/myproject/dist/src/file1.js] Inode:: 125 export {}; @@ -60,9 +60,9 @@ FsWatches:: /user/username/projects/myproject: *new* {"inode":4} /user/username/projects/myproject/dist: *new* - {"inode":120} + {"inode":122} /user/username/projects/myproject/dist/src: *new* - {"inode":121} + {"inode":123} /user/username/projects/myproject/src: *new* {"inode":5} /user/username/projects/myproject/src/file1.ts: *new* @@ -106,7 +106,7 @@ exitCode:: ExitStatus.undefined Change:: rename the file Input:: -//// [/user/username/projects/myproject/src/renamed.ts] Inode:: 124 +//// [/user/username/projects/myproject/src/renamed.ts] Inode:: 126 export const x = 10; //// [/user/username/projects/myproject/src/file2.ts] deleted @@ -125,9 +125,9 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/dist: - {"inode":120} + {"inode":122} /user/username/projects/myproject/dist/src: - {"inode":121} + {"inode":123} /user/username/projects/myproject/src: {"inode":5} /user/username/projects/myproject/src/file1.ts: @@ -167,7 +167,7 @@ Output:: -//// [/user/username/projects/myproject/dist/src/file1.js] file written with same contents Inode:: 123 +//// [/user/username/projects/myproject/dist/src/file1.js] file written with same contents Inode:: 125 PolledWatches:: /user/username/projects/myproject/src/file2.ts: @@ -183,9 +183,9 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/dist: - {"inode":120} + {"inode":122} /user/username/projects/myproject/dist/src: - {"inode":121} + {"inode":123} /user/username/projects/myproject/src: {"inode":5} /user/username/projects/myproject/src/file1.ts: @@ -248,7 +248,7 @@ Output:: -//// [/user/username/projects/myproject/dist/src/renamed.js] Inode:: 125 +//// [/user/username/projects/myproject/dist/src/renamed.js] Inode:: 127 export const x = 10; @@ -263,15 +263,15 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/dist: - {"inode":120} + {"inode":122} /user/username/projects/myproject/dist/src: - {"inode":121} + {"inode":123} /user/username/projects/myproject/src: {"inode":5} /user/username/projects/myproject/src/file1.ts: {"inode":6} /user/username/projects/myproject/src/renamed.ts: *new* - {"inode":124} + {"inode":126} /user/username/projects/myproject/tsconfig.json: {"inode":8} diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-with-outDir-and-declaration-enabled.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-with-outDir-and-declaration-enabled.js index 95270e505a57a..6f64aafc57994 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-with-outDir-and-declaration-enabled.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory-with-outDir-and-declaration-enabled.js @@ -46,11 +46,11 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 18 -//// [/user/username/projects/myproject/dist/src/file1.js] Inode:: 124 +//// [/user/username/projects/myproject/dist/src/file1.js] Inode:: 126 export {}; -//// [/user/username/projects/myproject/dist/src/file1.d.ts] Inode:: 125 +//// [/user/username/projects/myproject/dist/src/file1.d.ts] Inode:: 127 export {}; @@ -73,9 +73,9 @@ FsWatches:: /user/username/projects/myproject: *new* {"inode":4} /user/username/projects/myproject/dist: *new* - {"inode":122} + {"inode":124} /user/username/projects/myproject/dist/src: *new* - {"inode":123} + {"inode":125} /user/username/projects/myproject/node_modules: *new* {"inode":7} /user/username/projects/myproject/node_modules/file2: *new* @@ -123,7 +123,7 @@ exitCode:: ExitStatus.undefined Change:: Add new file, should schedule and run timeout to update directory watcher Input:: -//// [/user/username/projects/myproject/src/file3.ts] Inode:: 126 +//// [/user/username/projects/myproject/src/file3.ts] Inode:: 128 export const y = 10; @@ -167,11 +167,11 @@ Output:: -//// [/user/username/projects/myproject/dist/src/file3.js] Inode:: 127 +//// [/user/username/projects/myproject/dist/src/file3.js] Inode:: 129 export const y = 10; -//// [/user/username/projects/myproject/dist/src/file3.d.ts] Inode:: 128 +//// [/user/username/projects/myproject/dist/src/file3.d.ts] Inode:: 130 export declare const y = 10; @@ -194,9 +194,9 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/dist: - {"inode":122} + {"inode":124} /user/username/projects/myproject/dist/src: - {"inode":123} + {"inode":125} /user/username/projects/myproject/node_modules: {"inode":7} /user/username/projects/myproject/node_modules/file2: @@ -208,7 +208,7 @@ FsWatches:: /user/username/projects/myproject/src/file1.ts: {"inode":6} /user/username/projects/myproject/src/file3.ts: *new* - {"inode":126} + {"inode":128} /user/username/projects/myproject/tsconfig.json: {"inode":10} diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory.js index 905d2e6ba928d..a6e253ebbad18 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchDirectories/with-non-synchronous-watch-directory.js @@ -41,7 +41,7 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 18 -//// [/user/username/projects/myproject/src/file1.js] Inode:: 122 +//// [/user/username/projects/myproject/src/file1.js] Inode:: 124 export {}; @@ -184,7 +184,7 @@ Output:: -//// [/user/username/projects/myproject/src/file1.js] file written with same contents Inode:: 122 +//// [/user/username/projects/myproject/src/file1.js] file written with same contents Inode:: 124 PolledWatches:: /user/username/projects/myproject/node_modules: @@ -328,7 +328,7 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/node_modules: *new* - {"inode":123} + {"inode":125} /user/username/projects/myproject/src: {"inode":5} /user/username/projects/myproject/src/file1.ts: @@ -356,7 +356,7 @@ exitCode:: ExitStatus.undefined Change:: npm install index file in file2 Input:: -//// [/user/username/projects/myproject/node_modules/file2/index.d.ts] Inode:: 125 +//// [/user/username/projects/myproject/node_modules/file2/index.d.ts] Inode:: 127 export const x = 10; @@ -382,9 +382,9 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/node_modules: - {"inode":123} + {"inode":125} /user/username/projects/myproject/node_modules/file2: *new* - {"inode":124} + {"inode":126} /user/username/projects/myproject/src: {"inode":5} /user/username/projects/myproject/src/file1.ts: @@ -440,7 +440,7 @@ Output:: -//// [/user/username/projects/myproject/src/file1.js] file written with same contents Inode:: 122 +//// [/user/username/projects/myproject/src/file1.js] file written with same contents Inode:: 124 PolledWatches:: /user/username/projects/myproject/node_modules/file2/package.json: *new* @@ -462,11 +462,11 @@ FsWatches:: /user/username/projects/myproject: {"inode":4} /user/username/projects/myproject/node_modules: - {"inode":123} + {"inode":125} /user/username/projects/myproject/node_modules/file2: - {"inode":124} + {"inode":126} /user/username/projects/myproject/node_modules/file2/index.d.ts: *new* - {"inode":125} + {"inode":127} /user/username/projects/myproject/src: {"inode":5} /user/username/projects/myproject/src/file1.ts: diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching-extendedDiagnostics.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching-extendedDiagnostics.js index 36ffba444804a..0d8ee1a8f5b98 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching-extendedDiagnostics.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching-extendedDiagnostics.js @@ -76,7 +76,7 @@ Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/mypr //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 22 -//// [/user/username/projects/myproject/src/main.js] Inode:: 126 +//// [/user/username/projects/myproject/src/main.js] Inode:: 128 import { foo } from "bar"; foo(); @@ -172,7 +172,7 @@ exitCode:: ExitStatus.undefined Change:: add new folder to temp Input:: -//// [/user/username/projects/myproject/node_modules/bar/temp/fooBar/index.d.ts] Inode:: 128 +//// [/user/username/projects/myproject/node_modules/bar/temp/fooBar/index.d.ts] Inode:: 130 export function temp(): string; diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching.js index a10b3a438eb5d..b471f295986a7 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-excludeDirectories-option-with-recursive-directory-watching.js @@ -53,7 +53,7 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 22 -//// [/user/username/projects/myproject/src/main.js] Inode:: 126 +//// [/user/username/projects/myproject/src/main.js] Inode:: 128 import { foo } from "bar"; foo(); @@ -137,7 +137,7 @@ exitCode:: ExitStatus.undefined Change:: add new folder to temp Input:: -//// [/user/username/projects/myproject/node_modules/bar/temp/fooBar/index.d.ts] Inode:: 128 +//// [/user/username/projects/myproject/node_modules/bar/temp/fooBar/index.d.ts] Inode:: 130 export function temp(): string; diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-fallbackPolling-option.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-fallbackPolling-option.js index 18e4722dbefec..4e88af36578b9 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-fallbackPolling-option.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-fallbackPolling-option.js @@ -44,12 +44,12 @@ sysLog:: /user/username/projects/project:: Changing to watchFile //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/user/username/projects/project/commonFile1.js] Inode:: 119 +//// [/user/username/projects/project/commonFile1.js] Inode:: 121 "use strict"; let x = 1; -//// [/user/username/projects/project/commonFile2.js] Inode:: 120 +//// [/user/username/projects/project/commonFile2.js] Inode:: 122 "use strict"; let y = 1; diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-watchDirectory-option.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-watchDirectory-option.js index 261d5afc2e6a2..df91eec22803e 100644 --- a/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-watchDirectory-option.js +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchOptions/with-watchDirectory-option.js @@ -39,12 +39,12 @@ Output:: //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 15 -//// [/user/username/projects/project/commonFile1.js] Inode:: 119 +//// [/user/username/projects/project/commonFile1.js] Inode:: 121 "use strict"; let x = 1; -//// [/user/username/projects/project/commonFile2.js] Inode:: 120 +//// [/user/username/projects/project/commonFile2.js] Inode:: 122 "use strict"; let y = 1; diff --git a/tests/baselines/reference/tsserver/projectErrors/file-rename-on-wsl2.js b/tests/baselines/reference/tsserver/projectErrors/file-rename-on-wsl2.js index 45c84175e0ddd..83e1767b23c81 100644 --- a/tests/baselines/reference/tsserver/projectErrors/file-rename-on-wsl2.js +++ b/tests/baselines/reference/tsserver/projectErrors/file-rename-on-wsl2.js @@ -208,7 +208,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/username/workspaces/project/tsconfig.j Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /home/username/workspaces/project/src/b.ts 2:: WatchInfo: /home/username/workspaces/project/src/b.ts 500 undefined WatchType: Closed Script info Before request -//// [/home/username/workspaces/project/src/c.ts] Inode:: 122 +//// [/home/username/workspaces/project/src/c.ts] Inode:: 124 export const b = 10; //// [/home/username/workspaces/project/src/b.ts] deleted @@ -470,7 +470,7 @@ FsWatches:: /home/username/workspaces/project/src: {"inode":5} /home/username/workspaces/project/src/c.ts: *new* - {"inode":122} + {"inode":124} /home/username/workspaces/project/tsconfig.json: {"inode":8} diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location-with-currentDirectory-at-root.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location-with-currentDirectory-at-root.js index 55382cbcc664a..81a89e133ca8e 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location-with-currentDirectory-at-root.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location-with-currentDirectory-at-root.js @@ -118,10 +118,10 @@ TI:: [hh:mm:ss:mss] Updating types-registry npm package... TI:: [hh:mm:ss:mss] npm install --ignore-scripts types-registry@latest TI:: [hh:mm:ss:mss] Updated types-registry npm package TI:: typing installer creation complete -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 115 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 117 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 118 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 120 { "entries": {} } diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location.js index ab9d894f8a101..c5182cbdbbb3f 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails-in-global-typings-location.js @@ -133,10 +133,10 @@ TI:: [hh:mm:ss:mss] Updating types-registry npm package... TI:: [hh:mm:ss:mss] npm install --ignore-scripts types-registry@latest TI:: [hh:mm:ss:mss] Updated types-registry npm package TI:: typing installer creation complete -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 118 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 120 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 121 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 123 { "entries": {} } diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing-with-currentDirectory-at-root.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing-with-currentDirectory-at-root.js index d91a22073bd1a..14c335ce30c06 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing-with-currentDirectory-at-root.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing-with-currentDirectory-at-root.js @@ -22,10 +22,10 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 119 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 121 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 121 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 123 { "entries": {} } @@ -152,7 +152,7 @@ PolledWatches:: FsWatches:: /home/src/Library/Caches/typescript/package.json: *new* - {"inode":119} + {"inode":121} /home/src/tslibs/TS/Lib/lib.es2020.full.d.ts: *new* {"inode":20} diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing.js index 6e5660d19e190..db8e4e4d9173b 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-failing.js @@ -22,10 +22,10 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 122 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 124 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 124 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 126 { "entries": {} } @@ -167,7 +167,7 @@ PolledWatches:: FsWatches:: /home/src/Library/Caches/typescript/package.json: *new* - {"inode":122} + {"inode":124} /home/src/tslibs/TS/Lib/lib.es2020.full.d.ts: *new* {"inode":23} diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-with-currentDirectory-at-root.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-with-currentDirectory-at-root.js index 9a268c647c870..4869c2f55ae85 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-with-currentDirectory-at-root.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file-with-currentDirectory-at-root.js @@ -26,10 +26,10 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 121 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 123 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 123 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 125 { "entries": {} } @@ -161,7 +161,7 @@ PolledWatches:: FsWatches:: /home/src/Library/Caches/typescript/package.json: *new* - {"inode":121} + {"inode":123} /home/src/tslibs/TS/Lib/lib.es2020.full.d.ts: *new* {"inode":22} diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file.js index 4aca9f311e931..773b9ba630062 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-import-from-the-cache-file.js @@ -26,10 +26,10 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 124 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 126 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 126 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 128 { "entries": {} } @@ -176,7 +176,7 @@ PolledWatches:: FsWatches:: /home/src/Library/Caches/typescript/package.json: *new* - {"inode":124} + {"inode":126} /home/src/tslibs/TS/Lib/lib.es2020.full.d.ts: *new* {"inode":25} diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file-with-currentDirectory-at-root.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file-with-currentDirectory-at-root.js index a80882b4a7e58..8cea271c0ab5c 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file-with-currentDirectory-at-root.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file-with-currentDirectory-at-root.js @@ -26,10 +26,10 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 120 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 122 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 122 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 124 { "entries": {} } @@ -148,7 +148,7 @@ PolledWatches:: FsWatches:: /home/src/Library/Caches/typescript/package.json: *new* - {"inode":120} + {"inode":122} /home/src/tslibs/TS/Lib/lib.es2020.full.d.ts: *new* {"inode":21} diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file.js index 11d2c104decac..03aa17102ce63 100644 --- a/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file.js +++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolution-is-succeeds-in-global-typings-location-with-relative-import-from-the-cache-file.js @@ -26,10 +26,10 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/home/src/Library/Caches/typescript/package.json] Inode:: 123 +//// [/home/src/Library/Caches/typescript/package.json] Inode:: 125 { "private": true } -//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 125 +//// [/home/src/Library/Caches/typescript/node_modules/types-registry/index.json] Inode:: 127 { "entries": {} } @@ -163,7 +163,7 @@ PolledWatches:: FsWatches:: /home/src/Library/Caches/typescript/package.json: *new* - {"inode":123} + {"inode":125} /home/src/tslibs/TS/Lib/lib.es2020.full.d.ts: *new* {"inode":24} diff --git a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux-canUseWatchEvents.js b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux-canUseWatchEvents.js index d1e7164250d4b..a37b4954f5326 100644 --- a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux-canUseWatchEvents.js +++ b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux-canUseWatchEvents.js @@ -617,20 +617,20 @@ Custom watchDirectory:: Triggered Ignored:: {"id":8,"path":"/home/src/projects/p Custom watchDirectory:: Triggered Ignored:: {"id":8,"path":"/home/src/projects/project/node_modules/package1","recursive":true,"ignoreUpdate":true}:: /home/src/projects/project/node_modules/package1/tsconfig.tsbuildinfo.readable.baseline.txt created Custom watchDirectory:: Triggered Ignored:: {"id":8,"path":"/home/src/projects/project/node_modules/package1","recursive":true,"ignoreUpdate":true}:: /home/src/projects/project/node_modules/package1/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 131 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 133 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 132 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 134 export type FooType = "foo"; export type BarType = "bar"; -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 133 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 135 {"root":["./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 134 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 136 { "root": [ "./src/index.ts" @@ -1345,14 +1345,14 @@ Custom watchDirectory:: Triggered Ignored:: {"id":8,"path":"/home/src/projects/p Custom watchDirectory:: Triggered Ignored:: {"id":8,"path":"/home/src/projects/project/node_modules/package1","recursive":true,"ignoreUpdate":true}:: /home/src/projects/project/node_modules/package1/tsconfig.tsbuildinfo updated Custom watchDirectory:: Triggered Ignored:: {"id":8,"path":"/home/src/projects/project/node_modules/package1","recursive":true,"ignoreUpdate":true}:: /home/src/projects/project/node_modules/package1/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 134 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 136 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 136 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 138 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 137 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 139 export type FooType = "foo"; export type BarType = "bar"; diff --git a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux.js b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux.js index 49bae12be00dd..238a99ee99c3c 100644 --- a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux.js +++ b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-Linux.js @@ -479,20 +479,20 @@ After running Immedidate callback:: count: 0 Build dependencies Before running Timeout callback:: count: 1 7: timerToUpdateChildWatches -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 131 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 133 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 132 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 134 export type FooType = "foo"; export type BarType = "bar"; -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 133 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 135 {"root":["./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 134 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 136 { "root": [ "./src/index.ts" @@ -530,7 +530,7 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":130} + {"inode":132} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -667,9 +667,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: - {"inode":130} -/home/src/projects/project/packages/package1/dist/index.d.ts: *new* {"inode":132} +/home/src/projects/project/packages/package1/dist/index.d.ts: *new* + {"inode":134} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -870,9 +870,9 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/project/packages/package1/dist: - {"inode":130} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":132} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":134} Timeout callback:: count: 3 13: /home/src/projects/project/packages/package2/tsconfig.json *new* @@ -1300,14 +1300,14 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /home/src/projects/project Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/project/packages/package1/dist/index.d.ts 0:: WatchInfo: /home/src/projects/project/packages/package1/dist/index.d.ts 500 undefined WatchType: Closed Script info Before running Timeout callback:: count: 1 25: timerToUpdateChildWatches -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 134 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 136 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 136 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 138 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 137 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 139 export type FooType = "foo"; export type BarType = "bar"; @@ -1333,7 +1333,7 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist/index.d.ts: *new* - {"inode":137} + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -1391,9 +1391,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":135} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":137} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -1528,9 +1528,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: - {"inode":135} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":137} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: diff --git a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux-canUseWatchEvents.js b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux-canUseWatchEvents.js index 0326fa91015ca..0a4c10e4620f4 100644 --- a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux-canUseWatchEvents.js +++ b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux-canUseWatchEvents.js @@ -86,20 +86,20 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2016.full.d.ts] *Lib* Inode:: 35 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 131 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 133 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 132 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 134 export type FooType = "foo"; export type BarType = "bar"; -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 133 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 135 {"root":["./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 134 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 136 { "root": [ "./src/index.ts" @@ -971,14 +971,14 @@ Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/p Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/project/node_modules/package1","recursive":true,"ignoreUpdate":true}:: /home/src/projects/project/node_modules/package1/tsconfig.tsbuildinfo updated Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/project/node_modules/package1","recursive":true,"ignoreUpdate":true}:: /home/src/projects/project/node_modules/package1/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 134 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 136 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 136 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 138 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 137 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 139 export type FooType = "foo"; export type BarType = "bar"; diff --git a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js index 5a8e620dbe556..6979fda2c4f01 100644 --- a/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js +++ b/tests/baselines/reference/tsserver/symLinks/monorepo-style-sibling-packages-symlinked-package1-built-Linux.js @@ -86,20 +86,20 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2016.full.d.ts] *Lib* Inode:: 35 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 131 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 133 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 132 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 134 export type FooType = "foo"; export type BarType = "bar"; -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 133 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] Inode:: 135 {"root":["./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 134 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 136 { "root": [ "./src/index.ts" @@ -314,9 +314,9 @@ FsWatches:: /home/src/projects/project/packages/package1: *new* {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":130} -/home/src/projects/project/packages/package1/dist/index.d.ts: *new* {"inode":132} +/home/src/projects/project/packages/package1/dist/index.d.ts: *new* + {"inode":134} /home/src/projects/project/packages/package1/package.json: *new* {"inode":7} /home/src/projects/project/packages/package1/src: *new* @@ -516,9 +516,9 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/project/packages/package1/dist: - {"inode":130} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":132} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":134} Timeout callback:: count: 3 2: /home/src/projects/project/packages/package2/tsconfig.json *new* @@ -951,14 +951,14 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /home/src/projects/project Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/project/packages/package1/dist/index.d.ts 0:: WatchInfo: /home/src/projects/project/packages/package1/dist/index.d.ts 500 undefined WatchType: Closed Script info Before running Timeout callback:: count: 1 14: timerToUpdateChildWatches -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 133 -//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 134 -//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 136 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo] file written with same contents Inode:: 135 +//// [/home/src/projects/project/packages/package1/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 136 +//// [/home/src/projects/project/packages/package1/dist/index.js] Inode:: 138 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 137 +//// [/home/src/projects/project/packages/package1/dist/index.d.ts] Inode:: 139 export type FooType = "foo"; export type BarType = "bar"; @@ -984,7 +984,7 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist/index.d.ts: *new* - {"inode":137} + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -1042,9 +1042,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: *new* - {"inode":135} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":137} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: @@ -1179,9 +1179,9 @@ FsWatches:: /home/src/projects/project/packages/package1: {"inode":6} /home/src/projects/project/packages/package1/dist: - {"inode":135} -/home/src/projects/project/packages/package1/dist/index.d.ts: {"inode":137} +/home/src/projects/project/packages/package1/dist/index.d.ts: + {"inode":139} /home/src/projects/project/packages/package1/package.json: {"inode":7} /home/src/projects/project/packages/package1/src: diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux-canUseWatchEvents.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux-canUseWatchEvents.js index bc9547e671e6c..468b5edd5d3f6 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux-canUseWatchEvents.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux-canUseWatchEvents.js @@ -610,7 +610,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 151 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 153 export const a = 10; @@ -740,7 +740,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 152 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 154 export const a = 10; @@ -888,26 +888,26 @@ Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/b Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt created Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 156 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 157 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 158 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 159 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 160 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 161 { "root": [ "./src/c.ts", @@ -917,28 +917,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 163 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 164 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 165 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 166 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 167 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 168 { "root": [ "./src/a.ts", @@ -1451,7 +1451,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -1567,7 +1567,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -2237,40 +2237,40 @@ Custom watchDirectory:: Triggered Ignored:: {"id":25,"path":"/home/src/projects/ Custom watchDirectory:: Triggered Ignored:: {"id":25,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo updated Custom watchDirectory:: Triggered Ignored:: {"id":25,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 160 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 167 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 168 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux.js index 7ffaff3c28aa2..96e3ad09b2194 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-Linux.js @@ -430,7 +430,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 151 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 153 export const a = 10; @@ -560,7 +560,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 152 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 154 export const a = 10; @@ -691,26 +691,26 @@ After running Immedidate callback:: count: 0 Build dependencies Before running Timeout callback:: count: 1 9: timerToUpdateChildWatches -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 156 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 157 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 158 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 159 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 160 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 161 { "root": [ "./src/c.ts", @@ -720,28 +720,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 163 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 164 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 165 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 166 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 167 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 168 { "root": [ "./src/a.ts", @@ -780,7 +780,7 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":160} + {"inode":162} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -931,11 +931,11 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib: - {"inode":160} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":162} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":164} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":166} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -955,11 +955,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":153} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":155} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":157} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":159} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: @@ -1112,7 +1112,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -1228,7 +1228,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -1446,17 +1446,17 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib: - {"inode":160} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":162} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":164} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":166} /home/src/projects/c/3/c-impl/c/lib: - {"inode":153} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":155} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":157} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":159} Timeout callback:: count: 3 30: /home/src/projects/b/2/b-impl/b/tsconfig.json *new* @@ -1782,40 +1782,40 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /home/src/projects/a/1/a-i Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/a/1/a-impl/a/lib/index.d.ts 0:: WatchInfo: /home/src/projects/a/1/a-impl/a/lib/index.d.ts 500 undefined WatchType: Closed Script info Before running Timeout callback:: count: 1 37: timerToUpdateChildWatches -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 160 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 167 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 168 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; @@ -1847,9 +1847,9 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":180} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1873,9 +1873,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":175} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":47} @@ -1936,11 +1936,11 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":174} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":180} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1964,9 +1964,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":175} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":47} @@ -2090,11 +2090,11 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib: - {"inode":174} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":180} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -2114,11 +2114,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":169} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":175} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs-canUseWatchEvents.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs-canUseWatchEvents.js index 5bdaedf7334a0..c97d01dfbb25d 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs-canUseWatchEvents.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs-canUseWatchEvents.js @@ -610,7 +610,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 151 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 153 export const a = 10; @@ -740,7 +740,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 152 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 154 export const a = 10; @@ -877,26 +877,26 @@ Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/b Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo created Custom watchDirectory:: Triggered Ignored:: {"id":9,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt created Before request -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 156 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 157 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 158 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 159 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 160 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 161 { "root": [ "./src/c.ts", @@ -906,28 +906,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 163 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 164 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 165 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 166 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 167 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 168 { "root": [ "./src/a.ts", @@ -1440,7 +1440,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -1556,7 +1556,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -2217,40 +2217,40 @@ Custom watchDirectory:: Triggered Ignored:: {"id":25,"path":"/home/src/projects/ Custom watchDirectory:: Triggered Ignored:: {"id":25,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo updated Custom watchDirectory:: Triggered Ignored:: {"id":25,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 160 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 167 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 168 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs.js index ce347c1d4746d..57285360ad2c7 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-MacOs.js @@ -426,7 +426,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 151 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 153 export const a = 10; @@ -556,7 +556,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 152 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 154 export const a = 10; @@ -708,26 +708,26 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt :: WatchInfo: /home/src/projects/b/2/b-impl/b/node_modules/a 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 10: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 156 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 157 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 158 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 159 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 160 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 161 { "root": [ "./src/c.ts", @@ -737,28 +737,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 163 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 164 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 165 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 166 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 167 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 168 { "root": [ "./src/a.ts", @@ -891,9 +891,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":162} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":164} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":166} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -907,9 +907,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":155} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":157} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":159} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: @@ -1078,7 +1078,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/a/2/unrelated/anotherFile.ts :: WatchInfo: /home/src/projects/a 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 14: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -1202,7 +1202,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/c/4/unrelated/anotherFile.ts :: WatchInfo: /home/src/projects/c 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 16: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -1414,13 +1414,13 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib/a.d.ts: - {"inode":162} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: {"inode":164} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":166} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":155} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":157} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":159} FsWatchesRecursive:: /home/src/projects/a: @@ -1773,40 +1773,40 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/b/2/b-impl/b/node_modules/a/lib/index.d.ts :: WatchInfo: /home/src/projects/b/2/b-impl/b/node_modules/a 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 41: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 160 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 167 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 168 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; @@ -1836,9 +1836,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":180} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -1852,9 +1852,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":175} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":47} @@ -2013,9 +2013,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: - {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":180} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -2029,9 +2029,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":175} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux-canUseWatchEvents.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux-canUseWatchEvents.js index f6219df3fcaa7..1ade505c4f844 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux-canUseWatchEvents.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux-canUseWatchEvents.js @@ -95,26 +95,26 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 47 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 152 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 { "root": [ "./src/c.ts", @@ -124,28 +124,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 { "root": [ "./src/a.ts", @@ -739,7 +739,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 165 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 167 export const a = 10; @@ -855,7 +855,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 166 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 168 export const a = 10; @@ -971,7 +971,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -1087,7 +1087,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -1759,40 +1759,40 @@ Custom watchDirectory:: Triggered Ignored:: {"id":20,"path":"/home/src/projects/ Custom watchDirectory:: Triggered Ignored:: {"id":20,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo updated Custom watchDirectory:: Triggered Ignored:: {"id":20,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 156 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 157 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 163 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 164 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux.js index 2dc5de2af458a..637e35347505b 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-Linux.js @@ -95,26 +95,26 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 47 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 152 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 { "root": [ "./src/c.ts", @@ -124,28 +124,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 { "root": [ "./src/a.ts", @@ -337,11 +337,11 @@ FsWatches:: /home/src/projects: *new* {"inode":3} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":158} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":160} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* {"inode":162} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":164} /home/src/projects/a/1/a-impl/a/node_modules: *new* {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: *new* @@ -361,11 +361,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: *new* {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":151} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":153} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* {"inode":155} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":157} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: *new* @@ -509,7 +509,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 165 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 167 export const a = 10; @@ -625,7 +625,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 166 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 168 export const a = 10; @@ -741,7 +741,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -857,7 +857,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -1075,17 +1075,17 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib: - {"inode":158} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":160} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":162} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":164} /home/src/projects/c/3/c-impl/c/lib: - {"inode":151} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":153} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":155} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":157} Timeout callback:: count: 3 19: /home/src/projects/b/2/b-impl/b/tsconfig.json *new* @@ -1413,40 +1413,40 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /home/src/projects/a/1/a-i Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/a/1/a-impl/a/lib/index.d.ts 0:: WatchInfo: /home/src/projects/a/1/a-impl/a/lib/index.d.ts 500 undefined WatchType: Closed Script info Before running Timeout callback:: count: 1 26: timerToUpdateChildWatches -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 156 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 157 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 163 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 164 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; @@ -1478,9 +1478,9 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":180} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1504,9 +1504,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":175} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":47} @@ -1567,11 +1567,11 @@ FsWatches:: /home/src/projects/a/1/a-impl/a: {"inode":19} /home/src/projects/a/1/a-impl/a/lib: *new* - {"inode":174} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":180} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1595,9 +1595,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":175} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":47} @@ -1721,11 +1721,11 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib: - {"inode":174} -/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: +/home/src/projects/a/1/a-impl/a/lib/a.d.ts: {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":180} /home/src/projects/a/1/a-impl/a/node_modules: {"inode":25} /home/src/projects/a/1/a-impl/a/package.json: @@ -1745,11 +1745,11 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib: *new* - {"inode":169} -/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: +/home/src/projects/c/3/c-impl/c/lib/c.d.ts: {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":175} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs-canUseWatchEvents.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs-canUseWatchEvents.js index 5e36f000464f4..6847c33e03a2d 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs-canUseWatchEvents.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs-canUseWatchEvents.js @@ -95,26 +95,26 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 47 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 152 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 { "root": [ "./src/c.ts", @@ -124,28 +124,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 { "root": [ "./src/a.ts", @@ -739,7 +739,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 165 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 167 export const a = 10; @@ -855,7 +855,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 166 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 168 export const a = 10; @@ -971,7 +971,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in a Before running Timeout callback:: count: 0 -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -1087,7 +1087,7 @@ After running Immedidate callback:: count: 0 change in unrelated folder in c Before running Timeout callback:: count: 0 -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -1750,40 +1750,40 @@ Custom watchDirectory:: Triggered Ignored:: {"id":20,"path":"/home/src/projects/ Custom watchDirectory:: Triggered Ignored:: {"id":20,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo updated Custom watchDirectory:: Triggered Ignored:: {"id":20,"path":"/home/src/projects/b/2/b-impl/b/node_modules/a","recursive":true,"ignoreUpdate":true}:: /home/src/projects/b/2/b-impl/b/node_modules/a/tsconfig.tsbuildinfo.readable.baseline.txt updated Before request -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 156 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 157 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 163 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 164 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; diff --git a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs.js b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs.js index d2cc3f9018ca5..cb5392c206de1 100644 --- a/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs.js +++ b/tests/baselines/reference/tsserver/symLinks/packages-outside-project-folder-built-MacOs.js @@ -95,26 +95,26 @@ declare const console: { log(msg: any): void; }; //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* Inode:: 47 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 152 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 154 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 153 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 155 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 154 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 156 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 155 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 157 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 156 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] Inode:: 158 {"root":["./src/c.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 157 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 159 { "root": [ "./src/c.ts", @@ -124,28 +124,28 @@ export * from './c'; "size": 66 } -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 161 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 160 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 162 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 161 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 163 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 162 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 164 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 163 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] Inode:: 165 {"root":["./src/a.ts","./src/index.ts"],"version":"FakeTSVersion"} -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 164 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] Inode:: 166 { "root": [ "./src/a.ts", @@ -337,9 +337,9 @@ FsWatches:: /home/src/projects: *new* {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":160} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":162} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":164} /home/src/projects/a/1/a-impl/a/package.json: *new* {"inode":24} /home/src/projects/b: *new* @@ -353,9 +353,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: *new* {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":153} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":155} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":157} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: *new* @@ -515,7 +515,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/a/2/unrelated/somethingUnrelated.ts :: WatchInfo: /home/src/projects/a 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 2: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 165 +//// [/home/src/projects/a/2/unrelated/somethingUnrelated.ts] Inode:: 167 export const a = 10; @@ -639,7 +639,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/c/4/unrelated/somethingUnrelated.ts :: WatchInfo: /home/src/projects/c 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 4: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 166 +//// [/home/src/projects/c/4/unrelated/somethingUnrelated.ts] Inode:: 168 export const a = 10; @@ -763,7 +763,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/a/2/unrelated/anotherFile.ts :: WatchInfo: /home/src/projects/a 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 6: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 167 +//// [/home/src/projects/a/2/unrelated/anotherFile.ts] Inode:: 169 export const a = 10; @@ -887,7 +887,7 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/c/4/unrelated/anotherFile.ts :: WatchInfo: /home/src/projects/c 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 8: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 168 +//// [/home/src/projects/c/4/unrelated/anotherFile.ts] Inode:: 170 export const a = 10; @@ -1099,13 +1099,13 @@ FsWatches:: FsWatches *deleted*:: /home/src/projects/a/1/a-impl/a/lib/a.d.ts: - {"inode":160} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: {"inode":162} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":164} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":153} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":155} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":157} FsWatchesRecursive:: /home/src/projects/a: @@ -1460,40 +1460,40 @@ Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/b/2/b-impl/b/tsconfig.jso Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/b/2/b-impl/b/node_modules/a/lib/index.d.ts :: WatchInfo: /home/src/projects/b/2/b-impl/b/node_modules/a 1 undefined Project: /home/src/projects/b/2/b-impl/b/tsconfig.json WatchType: Failed Lookup Locations Before running Timeout callback:: count: 1 33: /home/src/projects/b/2/b-impl/b/tsconfig.jsonFailedLookupInvalidation -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 156 -//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 157 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 163 -//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 164 -//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 170 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo] file written with same contents Inode:: 158 +//// [/home/src/projects/c/3/c-impl/c/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 159 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo] file written with same contents Inode:: 165 +//// [/home/src/projects/a/1/a-impl/a/tsconfig.tsbuildinfo.readable.baseline.txt] file written with same contents Inode:: 166 +//// [/home/src/projects/c/3/c-impl/c/lib/c.js] Inode:: 172 export const c = 'test'; -//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 171 +//// [/home/src/projects/c/3/c-impl/c/lib/c.d.ts] Inode:: 173 export declare const c: string; -//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 172 +//// [/home/src/projects/c/3/c-impl/c/lib/index.js] Inode:: 174 export * from './c'; -//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 173 +//// [/home/src/projects/c/3/c-impl/c/lib/index.d.ts] Inode:: 175 export * from './c'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 175 +//// [/home/src/projects/a/1/a-impl/a/lib/a.js] Inode:: 177 export const a = 'test'; -//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 176 +//// [/home/src/projects/a/1/a-impl/a/lib/a.d.ts] Inode:: 178 export declare const a: string; -//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 177 +//// [/home/src/projects/a/1/a-impl/a/lib/index.js] Inode:: 179 export * from './a'; export * from 'c'; -//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 178 +//// [/home/src/projects/a/1/a-impl/a/lib/index.d.ts] Inode:: 180 export * from './a'; export * from 'c'; @@ -1523,9 +1523,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: *new* - {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: *new* + {"inode":180} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -1539,9 +1539,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: *new* - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: *new* + {"inode":175} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: {"inode":47} @@ -1700,9 +1700,9 @@ FsWatches:: /home/src/projects: {"inode":3} /home/src/projects/a/1/a-impl/a/lib/a.d.ts: - {"inode":176} -/home/src/projects/a/1/a-impl/a/lib/index.d.ts: {"inode":178} +/home/src/projects/a/1/a-impl/a/lib/index.d.ts: + {"inode":180} /home/src/projects/a/1/a-impl/a/package.json: {"inode":24} /home/src/projects/b: @@ -1716,9 +1716,9 @@ FsWatches:: /home/src/projects/b/2/b-impl/b/tsconfig.json: {"inode":36} /home/src/projects/c/3/c-impl/c/lib/c.d.ts: - {"inode":171} -/home/src/projects/c/3/c-impl/c/lib/index.d.ts: {"inode":173} +/home/src/projects/c/3/c-impl/c/lib/index.d.ts: + {"inode":175} /home/src/projects/c/3/c-impl/c/package.json: *new* {"inode":12} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js b/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js index a6cf6e23e0fb3..6f34489c85835 100644 --- a/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js +++ b/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js @@ -444,7 +444,7 @@ Info seq [hh:mm:ss:mss] event: "line": 34, "offset": 16 }, - "text": "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.typedarrays', 'decorators', 'decorators.legacy'.", + "text": "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'es2025', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.arraybuffer', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'es2024.arraybuffer', 'es2024.collection', 'es2024.object', 'es2024.promise', 'es2024.regexp', 'es2024.sharedmemory', 'es2024.string', 'es2025.collection', 'es2025.float16', 'es2025.intl', 'es2025.iterator', 'es2025.promise', 'es2025.regexp', 'esnext.asynciterable', 'esnext.symbol', 'esnext.bigint', 'esnext.weakref', 'esnext.object', 'esnext.regexp', 'esnext.string', 'esnext.float16', 'esnext.iterator', 'esnext.promise', 'esnext.array', 'esnext.collection', 'esnext.date', 'esnext.decorators', 'esnext.disposable', 'esnext.error', 'esnext.intl', 'esnext.sharedmemory', 'esnext.temporal', 'esnext.typedarrays', 'decorators', 'decorators.legacy'.", "code": 6046, "category": "error", "fileName": "/home/src/projects/project/tsconfig.json" diff --git a/tests/baselines/reference/tsserver/watchEnvironment/recursive-directory-does-not-watch-files-starting-with-dot-in-node_modules.js b/tests/baselines/reference/tsserver/watchEnvironment/recursive-directory-does-not-watch-files-starting-with-dot-in-node_modules.js index 9224132ea5117..9e61dd43d1269 100644 --- a/tests/baselines/reference/tsserver/watchEnvironment/recursive-directory-does-not-watch-files-starting-with-dot-in-node_modules.js +++ b/tests/baselines/reference/tsserver/watchEnvironment/recursive-directory-does-not-watch-files-starting-with-dot-in-node_modules.js @@ -216,30 +216,30 @@ ScriptInfos:: /a/username/workspace/project/tsconfig.json After writing ignored file or folder -//// [/a/username/workspace/project/node_modules/.cache/someFile.d.ts] Inode:: 126 +//// [/a/username/workspace/project/node_modules/.cache/someFile.d.ts] Inode:: 128 After writing ignored file or folder -//// [/a/username/workspace/project/node_modules/.cacheFile.ts] Inode:: 127 +//// [/a/username/workspace/project/node_modules/.cacheFile.ts] Inode:: 129 Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /a/username/workspace/project/.git :: WatchInfo: /a/username/workspace/project 0 undefined Project: /a/username/workspace/project/tsconfig.json WatchType: Failed Lookup Locations Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /a/username/workspace/project/.git :: WatchInfo: /a/username/workspace/project 0 undefined Project: /a/username/workspace/project/tsconfig.json WatchType: Failed Lookup Locations After writing ignored file or folder -//// [/a/username/workspace/project/.git/someFile.d.ts] Inode:: 129 +//// [/a/username/workspace/project/.git/someFile.d.ts] Inode:: 131 Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /a/username/workspace/project/.gitCache.d.ts :: WatchInfo: /a/username/workspace/project 0 undefined Project: /a/username/workspace/project/tsconfig.json WatchType: Failed Lookup Locations Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /a/username/workspace/project/.gitCache.d.ts :: WatchInfo: /a/username/workspace/project 0 undefined Project: /a/username/workspace/project/tsconfig.json WatchType: Failed Lookup Locations After writing ignored file or folder -//// [/a/username/workspace/project/.gitCache.d.ts] Inode:: 130 +//// [/a/username/workspace/project/.gitCache.d.ts] Inode:: 132 After writing ignored file or folder -//// [/a/username/workspace/project/src/.#field.ts] Inode:: 131 +//// [/a/username/workspace/project/src/.#field.ts] Inode:: 133 diff --git a/tests/baselines/reference/tsserver/watchEnvironment/uses-dynamic-polling-when-file-is-added-to-subfolder.js b/tests/baselines/reference/tsserver/watchEnvironment/uses-dynamic-polling-when-file-is-added-to-subfolder.js index 4247360daf190..dfc89cb4e0bdb 100644 --- a/tests/baselines/reference/tsserver/watchEnvironment/uses-dynamic-polling-when-file-is-added-to-subfolder.js +++ b/tests/baselines/reference/tsserver/watchEnvironment/uses-dynamic-polling-when-file-is-added-to-subfolder.js @@ -240,7 +240,7 @@ After request Before running Timeout callback:: count: 1 1: pollPollingIntervalQueue -//// [/a/username/workspace/project/src/file2.ts] Inode:: 123 +//// [/a/username/workspace/project/src/file2.ts] Inode:: 125 @@ -354,7 +354,7 @@ FsWatches:: /a/username/workspace/project/src/file1.ts: {"inode":7} /a/username/workspace/project/src/file2.ts: *new* - {"inode":123} + {"inode":125} /a/username/workspace/project/tsconfig.json: {"inode":8} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/watchEnvironment/uses-non-recursive-watchDirectory-when-file-is-added-to-subfolder.js b/tests/baselines/reference/tsserver/watchEnvironment/uses-non-recursive-watchDirectory-when-file-is-added-to-subfolder.js index bfa42afd9c5ae..1dd5840997cea 100644 --- a/tests/baselines/reference/tsserver/watchEnvironment/uses-non-recursive-watchDirectory-when-file-is-added-to-subfolder.js +++ b/tests/baselines/reference/tsserver/watchEnvironment/uses-non-recursive-watchDirectory-when-file-is-added-to-subfolder.js @@ -250,7 +250,7 @@ Before running Timeout callback:: count: 3 1: /a/username/workspace/project/tsconfig.json 2: *ensureProjectForOpenFiles* 3: /a/username/workspace/project/tsconfig.jsonFailedLookupInvalidation -//// [/a/username/workspace/project/src/file2.ts] Inode:: 123 +//// [/a/username/workspace/project/src/file2.ts] Inode:: 125 @@ -328,7 +328,7 @@ FsWatches:: /a/username/workspace/project/src/file1.ts: {"inode":7} /a/username/workspace/project/src/file2.ts: *new* - {"inode":123} + {"inode":125} /a/username/workspace/project/tsconfig.json: {"inode":8} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/watchEnvironment/uses-watchFile-when-file-is-added-to-subfolder.js b/tests/baselines/reference/tsserver/watchEnvironment/uses-watchFile-when-file-is-added-to-subfolder.js index 7838b4332eeda..c932bc9d42559 100644 --- a/tests/baselines/reference/tsserver/watchEnvironment/uses-watchFile-when-file-is-added-to-subfolder.js +++ b/tests/baselines/reference/tsserver/watchEnvironment/uses-watchFile-when-file-is-added-to-subfolder.js @@ -255,7 +255,7 @@ Before running Timeout callback:: count: 3 3: /a/username/workspace/project/tsconfig.json 4: *ensureProjectForOpenFiles* 5: /a/username/workspace/project/tsconfig.jsonFailedLookupInvalidation -//// [/a/username/workspace/project/src/file2.ts] Inode:: 123 +//// [/a/username/workspace/project/src/file2.ts] Inode:: 125 @@ -322,7 +322,7 @@ FsWatches:: /a/username/workspace/project/src/file1.ts: {"inode":7} /a/username/workspace/project/src/file2.ts: *new* - {"inode":123} + {"inode":125} /a/username/workspace/project/tsconfig.json: {"inode":8} /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watching-npm-install-in-codespaces-where-workspaces-folder-is-hosted-at-root.js b/tests/baselines/reference/tsserver/watchEnvironment/watching-npm-install-in-codespaces-where-workspaces-folder-is-hosted-at-root.js index 8271d2defa76b..ca419f6908610 100644 --- a/tests/baselines/reference/tsserver/watchEnvironment/watching-npm-install-in-codespaces-where-workspaces-folder-is-hosted-at-root.js +++ b/tests/baselines/reference/tsserver/watchEnvironment/watching-npm-install-in-codespaces-where-workspaces-folder-is-hosted-at-root.js @@ -626,7 +626,7 @@ Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /workspaces/somerepo/ Info seq [hh:mm:ss:mss] Scheduled: /workspaces/somerepo/src/tsconfig.jsonFailedLookupInvalidation, Cancelled earlier one Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /workspaces/somerepo/node_modules :: WatchInfo: /workspaces/somerepo 0 undefined Project: /workspaces/somerepo/src/tsconfig.json WatchType: Failed Lookup Locations Before request -//// [/workspaces/somerepo/node_modules/@types/random-seed/index.d.ts] Inode:: 127 +//// [/workspaces/somerepo/node_modules/@types/random-seed/index.d.ts] Inode:: 129 export function randomSeed(): string; @@ -644,7 +644,7 @@ FsWatches:: /workspaces/somerepo: {"inode":2} /workspaces/somerepo/node_modules: *new* - {"inode":124} + {"inode":126} /workspaces/somerepo/src: {"inode":3} /workspaces/somerepo/src/tsconfig.json: @@ -732,7 +732,7 @@ FsWatches:: /workspaces/somerepo: {"inode":2} /workspaces/somerepo/node_modules: - {"inode":124} + {"inode":126} /workspaces/somerepo/src: {"inode":3} /workspaces/somerepo/src/tsconfig.json: @@ -881,11 +881,11 @@ FsWatches:: /workspaces/somerepo: {"inode":2} /workspaces/somerepo/node_modules: - {"inode":124} + {"inode":126} /workspaces/somerepo/node_modules/@types: *new* - {"inode":125} + {"inode":127} /workspaces/somerepo/node_modules/@types/random-seed: *new* - {"inode":126} + {"inode":128} /workspaces/somerepo/src: {"inode":3} /workspaces/somerepo/src/tsconfig.json: diff --git a/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts b/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts index d1eb7ba7a46f9..50859bb29553c 100644 --- a/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts +++ b/tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.ts @@ -48,3 +48,4 @@ const testPromiseAny = Promise.any([]); const testStringReplaceAll = "".replaceAll(); // esnext +const testDateToTemporalInstant = new Date().toTemporalInstant(); diff --git a/tests/cases/compiler/temporal.ts b/tests/cases/compiler/temporal.ts new file mode 100644 index 0000000000000..8163d6cb67f17 --- /dev/null +++ b/tests/cases/compiler/temporal.ts @@ -0,0 +1,1822 @@ +// @target: es2020 +// @lib: es6,es2021.intl,esnext.date,esnext.intl,esnext.temporal,dom +// @strict: true + +/** + * Test cases derived from documentation at tc39/proposal-temporal, + * under the following license: + * + * Copyright 2017, 2018, 2019, 2020 ECMA International + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +{ + const instant = Temporal.Instant.from("2020-01-01T00:00+05:30"); // => 2019-12-31T18:30:00Z + instant.epochNanoseconds; // => 1577817000000000000n + + // `Temporal.Instant` lacks properties that depend on time zone or calendar + instant.year; // => undefined + + const zdtTokyo = instant.toZonedDateTimeISO("Asia/Tokyo"); // => 2020-01-01T03:30:00+09:00[Asia/Tokyo] + zdtTokyo.year; // => 2020 + zdtTokyo.toPlainDate(); // => 2020-01-01 +} + +{ + // Convert from `Temporal.Instant` to `Date` (which uses millisecond precision) + const instant = Temporal.Instant.from("2020-01-01T00:00:00.123456789+05:30"); + // => 2019-12-31T18:30:00.123456789Z + const date = new Date(instant.epochMilliseconds); + date.toISOString(); // => 2019-12-31T18:30:00.123Z + + // Convert from `Date` to `Temporal.Instant` + const sameInstant = date.toTemporalInstant(); // => 2019-12-31T18:30:00.123Z +} + +{ + const date = new Date(2019, 11, 31, 18, 30); // => Tue Dec 31 2019 18:30:00 GMT-0800 (Pacific Standard Time) + const instant = date.toTemporalInstant(); // => 2020-01-01T02:30:00Z + const zonedDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId()); + // => 2019-12-31T18:30:00-08:00[America/Los_Angeles] + zonedDateTime.day; // => 31 + const dateOnly = zonedDateTime.toPlainDate(); // => 2019-12-31 +} + +{ + const instant = new Temporal.Instant(1553906700000000000n); + // When was the Unix epoch? + const epoch = new Temporal.Instant(0n); // => 1970-01-01T00:00:00Z + // Dates before the Unix epoch are negative + const turnOfTheCentury = new Temporal.Instant(-2208988800000000000n); // => 1900-01-01T00:00:00Z +} + +{ + let instant: Temporal.Instant; + instant = Temporal.Instant.from("2019-03-30T01:45:00+01:00[Europe/Berlin]"); + instant = Temporal.Instant.from("2019-03-30T01:45+01:00"); + instant = Temporal.Instant.from("2019-03-30T00:45Z"); + instant === Temporal.Instant.from(instant); // => false +} + +{ + const legacyDate = new Date("1995-12-17T03:24Z"); + let instant: Temporal.Instant; + instant = Temporal.Instant.fromEpochMilliseconds(legacyDate.getTime()); // => 1995-12-17T03:24:00Z + instant = legacyDate.toTemporalInstant(); // recommended +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + const three = Temporal.Instant.fromEpochMilliseconds(1.2e12); + const sorted = [three, one, two].sort(Temporal.Instant.compare); + sorted.join(" "); + // => '2001-09-09T01:46:40Z 2004-11-09T11:33:20Z 2008-01-10T21:20:00Z' +} + +{ + const instant = Temporal.Instant.from("2019-03-30T00:45Z"); + new Date(instant.epochMilliseconds); // => 2019-03-30T00:45:00.000Z + + // If you need epoch seconds data: + const epochSecs = Math.floor(instant.epochMilliseconds / 1000); // => 1553906700 + + const ns = instant.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); +} + +{ + // Converting a specific exact time to a calendar date / wall-clock time + let timestamp: Temporal.Instant; + timestamp = Temporal.Instant.fromEpochMilliseconds(1553993100_000); + timestamp.toZonedDateTimeISO("Europe/Berlin"); // => 2019-03-31T01:45:00+01:00[Europe/Berlin] + timestamp.toZonedDateTimeISO("UTC"); // => 2019-03-31T00:45:00+00:00[UTC] + timestamp.toZonedDateTimeISO("-08:00"); // => 2019-03-30T16:45:00-08:00[-08:00] + + // What time was the Unix epoch (timestamp 0) in Bell Labs (Murray Hill, New Jersey, USA) in the Gregorian calendar? + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + epoch.toZonedDateTimeISO("America/New_York").withCalendar("gregory"); + // => 1969-12-31T19:00:00-05:00[America/New_York][u-ca=gregory] + + // What time was the Unix epoch in Tokyo in the Japanese calendar? + const zdt = epoch.toZonedDateTimeISO("Asia/Tokyo").withCalendar("japanese"); + // => 1970-01-01T09:00:00+09:00[Asia/Tokyo][u-ca=japanese] + console.log(zdt.eraYear, zdt.era); + // => '45 showa' +} + +{ + // Temporal.Instant representing five hours from now + Temporal.Now.instant().add({ hours: 5 }); + const fiveHours = Temporal.Duration.from({ hours: 5 }); + Temporal.Now.instant().add(fiveHours); +} + +{ + // Temporal.Instant representing this time an hour ago + Temporal.Now.instant().subtract({ hours: 1 }); + const oneHour = Temporal.Duration.from({ hours: 1 }); + Temporal.Now.instant().subtract(oneHour); +} + +{ + const startOfMoonMission = Temporal.Instant.from("1969-07-16T13:32:00Z"); + const endOfMoonMission = Temporal.Instant.from("1969-07-24T16:50:35Z"); + const missionLength = startOfMoonMission.until(endOfMoonMission, { largestUnit: "hour" }); + // => PT195H18M35S + missionLength.toLocaleString(); + // example output: '195 hours 18 minutes 35 seconds' + + // Rounding, for example if you don't care about the minutes and seconds + const approxMissionLength = startOfMoonMission.until(endOfMoonMission, { + largestUnit: "hour", + smallestUnit: "hour", + }); + // => PT195H + + // A billion (10^9) seconds since the epoch in different units + const epoch = Temporal.Instant.fromEpochMilliseconds(0); + const billion = Temporal.Instant.fromEpochMilliseconds(1e9); + epoch.until(billion); + // => PT1000000000S + epoch.until(billion, { largestUnit: "hour" }); + // => PT277777H46M40S + const ns = epoch.until(billion, { largestUnit: "nanosecond" }); + // => PT1000000000S + ns.add({ nanoseconds: 1 }); + // => PT1000000000S + // (lost precision) + + // Calculate the difference in years, eliminating the ambiguity by + // explicitly using the corresponding calendar date in UTC: + epoch.toZonedDateTimeISO("UTC").until( + billion.toZonedDateTimeISO("UTC"), + { largestUnit: "year" }, + ); + // => P31Y8M8DT1H46M40S +} + +{ + const instant = Temporal.Instant.from("2019-03-30T02:45:59.999999999Z"); + + // Round to a particular unit + instant.round({ smallestUnit: "second" }); // => 2019-03-30T02:46:00Z + // Round to an increment of a unit, e.g. an hour: + instant.round({ roundingIncrement: 60, smallestUnit: "minute" }); + // => 2019-03-30T03:00:00Z + // Round to the same increment but round down instead: + instant.round({ roundingIncrement: 60, smallestUnit: "minute", roundingMode: "floor" }); + // => 2019-03-30T02:00:00Z +} + +{ + const one = Temporal.Instant.fromEpochMilliseconds(1.0e12); + const two = Temporal.Instant.fromEpochMilliseconds(1.1e12); + one.equals(two); // => false + one.equals(one); // => true +} + +{ + const instant = Temporal.Instant.fromEpochMilliseconds(1574074321816); + instant.toString(); // => '2019-11-18T10:52:01.816Z' + instant.toString({ timeZone: "UTC" }); + // => '2019-11-18T10:52:01.816+00:00' + instant.toString({ timeZone: "Asia/Seoul" }); + // => '2019-11-18T19:52:01.816+09:00' + + instant.toString({ smallestUnit: "minute" }); + // => '2019-11-18T10:52Z' + instant.toString({ fractionalSecondDigits: 0 }); + // => '2019-11-18T10:52:01Z' + instant.toString({ fractionalSecondDigits: 4 }); + // => '2019-11-18T10:52:01.8160Z' + instant.toString({ smallestUnit: "second", roundingMode: "halfExpand" }); + // => '2019-11-18T10:52:02Z' +} + +{ + const instant = Temporal.Instant.from("2019-11-18T11:00:00.000Z"); + instant.toLocaleString(); // example output: '2019-11-18, 3:00:00 a.m.' + instant.toLocaleString("de-DE"); // example output: '18.11.2019, 03:00:00' + instant.toLocaleString("de-DE", { + timeZone: "Europe/Berlin", + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + timeZoneName: "long", + }); // => '18.11.2019, 12:00 Mitteleuropäische Normalzeit' + instant.toLocaleString("en-US-u-nu-fullwide-hc-h12", { + timeZone: "Asia/Kolkata", + }); // => '11/18/2019, 4:30:00 PM' +} + +{ + // UNIX epoch in California + new Temporal.ZonedDateTime(0n, "America/Los_Angeles", "iso8601"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); + // => 1969-12-31T16:00:00-08:00[America/Los_Angeles] + // same, but shorter +} + +{ + let zdt: Temporal.ZonedDateTime; + + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); + zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); + zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); + + zdt = Temporal.ZonedDateTime.from({ + timeZone: "America/Los_Angeles", + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] + + // Different overflow modes + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00+01:00[Europe/Paris] + zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws RangeError +} + +{ + const arr = [ + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/Toronto]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30-05:00[America/New_York]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+01:00[Europe/Brussels]"), + Temporal.ZonedDateTime.from("2020-02-01T12:30+00:00[Europe/London]"), + ]; + const sorted = arr.sort(Temporal.ZonedDateTime.compare); + JSON.stringify(sorted, undefined, 2); + // => + // '[ + // "2020-02-01T12:30+01:00[Europe/Brussels]", + // "2020-02-01T12:30+00:00[Europe/London]", + // "2020-02-01T12:30-05:00[America/Toronto]", + // "2020-02-01T12:30-05:00[America/New_York]" + // ]' +} + +{ + const dt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500[Europe/Rome]"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-02-01T12:30+09:00[Asia/Tokyo]"); + const epochMs = zdt.epochMilliseconds; + // => 1580527800000 + zdt.toInstant().epochMilliseconds; + // => 1580527800000 + const legacyDate = new Date(epochMs); + // => 2020-02-01T03:30:00.000Z + // (if the system time zone is America/Los_Angeles) + const epochNanos = zdt.epochNanoseconds; + // => 1580527800000000000n + + // If you need epoch seconds data: + const epochSecs = Math.floor(zdt.epochMilliseconds / 1000); // => 1553906700 + // => 1580527800 + + // If you need epoch microseconds data: + // (Note the extra check for correct floor rounding with bigints) + const ns = zdt.epochNanoseconds; + const epochMicros = ns / 1000n + ((ns % 1000n) < 0n ? -1n : 0n); + // => 1580527800000000n +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + `Time zone is: ${zdt.timeZoneId}`; + // => 'Time zone is: America/Los_Angeles' + zdt.withTimeZone("Asia/Kolkata").timeZoneId; + // => Asia/Kolkata + zdt.withTimeZone("Asia/Calcutta").timeZoneId; + // => Asia/Calcutta (does not follow links in the IANA Time Zone Database) + + zdt.withTimeZone("europe/paris").timeZoneId; + // => Europe/Paris (normalized to match IANA Time Zone Database capitalization) + + zdt.withTimeZone("+05:00").timeZoneId; + // => +05:00 + zdt.withTimeZone("+05").timeZoneId; + // => +05:00 (normalized to ±HH:MM) + zdt.withTimeZone("+0500").timeZoneId; + // => +05:00 (normalized to ±HH:MM) +} + +{ + const date = Temporal.ZonedDateTime.from("-000015-01-01T12:30[Europe/Rome][u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][zdt.dayOfWeek - 1]; // => 'THU' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + // ISO ordinal date + console.log(zdt.year, zdt.dayOfYear); // => '1995 341' +} + +{ + const zdt = Temporal.ZonedDateTime.from("2022-01-01T03:24-08:00[America/Los_Angeles]"); + // ISO week date + console.log(zdt.yearOfWeek, zdt.weekOfYear, zdt.dayOfWeek); // => '2021 52 6' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24-08:00[America/Los_Angeles]"); + zdt.daysInWeek; // => 7 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const zdt = Temporal.Now.zonedDateTimeISO().with({ month }); + monthsByDays[zdt.daysInMonth] = (monthsByDays[zdt.daysInMonth] || []).concat(zdt); + } + + const strings = monthsByDays[30].map(zdt => zdt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const zdt = Temporal.Now.zonedDateTimeISO(); + const percent = zdt.dayOfYear / zdt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} + +{ + const zdt = Temporal.ZonedDateTime.from("1900-01-01T12:00+09:00[Asia/Tokyo]"); + zdt.monthsInYear; // => 12 +} + +{ + // Is this year a leap year? + const zdt = Temporal.Now.zonedDateTimeISO(); + zdt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + zdt.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const zdt = Temporal.ZonedDateTime.from("2010-11-07T23:00:00-03:30[America/St_Johns]"); + zdt.hoursInDay; // 25 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offsetNanoseconds; + // => -25200000000000 + // (-7 * 3600 * 1e9) +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + zdt.offset; + // => '-07:00' + zdt.withTimeZone("Asia/Kolkata").offset; + // => '+05:30' + + const minus8Hours = "-08:00"; + const daylightTime0130 = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); + // => 2020-11-01T01:30:00-07:00[America/Los_Angeles] + // This is Pacific Daylight Time 1:30AM + const repeated0130 = daylightTime0130.with({ offset: minus8Hours }); + // => 2020-11-01T01:30:00-08:00[America/Los_Angeles] + // This is Pacific Standard Time 1:30AM +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:00-06:00[America/Chicago]"); + zdt.with({ year: 2015, minute: 31 }); // => 2015-12-07T03:31:00-06:00[America/Chicago] +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + zdt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00-08:00[America/Los_Angeles] + const time = Temporal.PlainTime.from("11:22"); + zdt.withPlainTime(time); // => 2015-12-07T11:22:00-08:00[America/Los_Angeles] + zdt.withPlainTime("12:34"); // => 2015-12-07T12:34:00-08:00[America/Los_Angeles] + + // easier for chaining + zdt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00-08:00[America/Los_Angeles] +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+09:00[Asia/Tokyo]"); + zdt.toString(); // => '1995-12-07T03:24:30+09:00[Asia/Tokyo]' + zdt.withTimeZone("Africa/Accra").toString(); // => '1995-12-06T18:24:30+00:00[Africa/Accra]' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]"); + `${zdt.era} ${zdt.eraYear}`; // => 'heisei 7' + zdt.withCalendar("gregory").eraYear; // => 1995 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const laterDay = zdt.add({ days: 1 }); + // => 2020-03-09T00:00:00-07:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + laterDay.since(zdt, { largestUnit: "hour" }).hours; + // => 23 + // because one clock hour lost to DST + + const laterHours = zdt.add({ hours: 24 }); + // => 2020-03-09T01:00:00-07:00[America/Los_Angeles] + // Adding time units doesn't adjust for DST. Result is 1:00AM: 24 real-world + // hours later because a clock hour was skipped by DST. + laterHours.since(zdt, { largestUnit: "hour" }).hours; // => 24 +} + +{ + const zdt = Temporal.ZonedDateTime.from("2020-03-09T00:00-07:00[America/Los_Angeles]"); + // Add a day to get midnight on the day after DST starts + const earlierDay = zdt.subtract({ days: 1 }); + // => 2020-03-08T00:00:00-08:00[America/Los_Angeles] + // Note that the new offset is different, indicating the result is adjusted for DST. + earlierDay.since(zdt, { largestUnit: "hour" }).hours; + // => -23 + // because one clock hour lost to DST + + const earlierHours = zdt.subtract({ hours: 24 }); + // => 2020-03-07T23:00:00-08:00[America/Los_Angeles] + // Subtracting time units doesn't adjust for DST. Result is 11:00PM: 24 real-world + // hours earlier because a clock hour was skipped by DST. + earlierHours.since(zdt, { largestUnit: "hour" }).hours; // => -24 +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt1.until(zdt2); + // => PT202956H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + zdt2.until(zdt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + zdt1.until(zdt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + zdt1.until(zdt2, { smallestUnit: "second" }); + // => PT202956H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.ZonedDateTime.from({ year: 2020, month, day: 1, timeZone: "Asia/Seoul" })); + jan1.until(feb1, { largestUnit: "day" }); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1, { largestUnit: "day" }); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1, { largestUnit: "day" }); // => P60D +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+05:30[Asia/Kolkata]"); + const zdt2 = Temporal.ZonedDateTime.from("2019-01-31T15:30+05:30[Asia/Kolkata]"); + zdt2.since(zdt1); // => PT202956H5M29.9999965S +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500-08:00[America/Los_Angeles]"); + + // Round to a particular unit + zdt.round({ smallestUnit: "hour" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] + // Round to an increment of a unit, e.g. half an hour: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00-08:00[America/Los_Angeles] + // Round to the same increment but round down instead: + zdt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00-08:00[America/Los_Angeles] +} + +{ + const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); + zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] +} + +{ + let duration: Temporal.Duration; + // How long until the next offset change from now, in the current location? + const tz = Temporal.Now.timeZoneId(); + const now = Temporal.Now.zonedDateTimeISO(tz); + const nextTransition = now.getTimeZoneTransition("next"); + duration = nextTransition!.since(now); + duration.toLocaleString(); // output will vary + + // How long until the previous offset change from now, in the current location? + const previousTransition = now.getTimeZoneTransition("previous"); + duration = now.since(previousTransition!); + duration.toLocaleString(); // output will vary +} + +{ + const zdt1 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Paris]"); + const zdt2 = Temporal.ZonedDateTime.from("1995-12-07T03:24:30.000003500+01:00[Europe/Brussels]"); + zdt1.equals(zdt2); // => false (same offset but different time zones) + zdt1.equals(zdt1); // => true + + // To compare time zone IDs, use withTimeZone() with each ID on the same + // ZonedDateTime instance, and use equals() to compare + const kolkata = zdt1.withTimeZone("Asia/Kolkata"); + kolkata.equals(zdt1.withTimeZone("Asia/Calcutta")); // => true + + // Offset time zones are never equivalent to named time zones + kolkata.equals(zdt1.withTimeZone("+05:30")); // => false + const zeroOffset = zdt1.withTimeZone("+00:00"); + zeroOffset.equals(zdt1.withTimeZone("UTC")); // => false + + // For offset time zones, any valid format is accepted + zeroOffset.equals(zdt1.withTimeZone("+00:00")); // => true + zeroOffset.equals(zdt1.withTimeZone("+0000")); // => true + zeroOffset.equals(zdt1.withTimeZone("+00")); // => true +} + +{ + let zdt: Temporal.ZonedDateTime; + zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: "Africa/Lagos" }); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos]' + zdt = zdt.withCalendar("japanese"); + zdt.toString(); // => '2019-12-01T12:00:00+01:00[Africa/Lagos][u-ca=japanese]' +} + +{ + const zdt = Temporal.ZonedDateTime.from("2019-12-01T12:00+01:00[Europe/Berlin]"); + zdt.toLocaleString(); // example output: 12/1/2019, 12:00:00 PM + zdt.toLocaleString("de-DE"); // => '1.12.2019, 12:00:00 MEZ' + const options = { weekday: "long", year: "numeric", month: "long", day: "numeric" } as const; + zdt.toLocaleString("de-DE", options); // => 'Sonntag, 1. Dezember 2019' + /* WRONG */ zdt.toLocaleString("de-DE", { timeZone: "Pacific/Auckland" }); + // => RangeError: Time zone option Pacific/Auckland does not match actual time zone Europe/Berlin + zdt.withTimeZone("Pacific/Auckland").toLocaleString("de-DE"); // => '2.12.2019, 0:00:00 GMT+13' + zdt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/1/2019, 12:00:00 PM GMT+1' +} + +{ + const zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Johannesburg]"); + zdt.toInstant(); // => 1995-12-07T01:24:30Z + zdt.toPlainDateTime(); // => 1995-12-07T03:24:30 + zdt.toPlainDate(); // => 1995-12-07 + zdt.toPlainTime(); // => 03:24:30 + zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 + zdt.toPlainDate().toPlainMonthDay(); // => 12-07 +} + +{ + // Pi day in 2020 + const date = new Temporal.PlainDate(2020, 3, 14); // => 2020-03-14 +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); // => 2006-08-24 + date = Temporal.PlainDate.from("20060824"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27"); // => 2006-08-24 + date = Temporal.PlainDate.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 2006-08-24 + date === Temporal.PlainDate.from(date); // => false + + date = Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }); // => 2006-08-24 + date = Temporal.PlainDate.from(Temporal.PlainDateTime.from("2006-08-24T15:43:27")); + // => 2006-08-24 + // same as above; Temporal.PlainDateTime has year, month, and day properties + + date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: "islamic" }); + // => 2006-08-24[u-ca=islamic] + + // Different overflow modes + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01 + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31 + date = Temporal.PlainDate.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + date = Temporal.PlainDate.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainDate.from("2006-08-24"); + const two = Temporal.PlainDate.from("2015-07-14"); + const three = Temporal.PlainDate.from("1930-02-18"); + const sorted = [one, two, three].sort(Temporal.PlainDate.compare); + sorted.join(" "); // => '1930-02-18 2006-08-24 2015-07-14' +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.year; // => 2006 + date.month; // => 8 + date.monthCode; // => 'M08' + date.day; // => 24 + + date = Temporal.PlainDate.from("2019-02-23[u-ca=hebrew]"); + date.year; // => 5779 + date.month; // => 6 + date.monthCode; // => 'M05L' + date.day; // => 18 +} + +{ + const date = Temporal.PlainDate.from("-000015-01-01[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][date.dayOfWeek - 1]; // => 'THU' +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + // ISO ordinal date + console.log(date.year, date.dayOfYear); // => '2006 236' +} + +{ + const date = Temporal.PlainDate.from("2022-01-01"); + // ISO week date + console.log(date.yearOfWeek, date.weekOfYear, date.dayOfWeek); // => '2021 52 6' +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.daysInWeek; // => 7 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const date = Temporal.Now.plainDateISO().with({ month }); + monthsByDays[date.daysInMonth] = (monthsByDays[date.daysInMonth] || []).concat(date); + } + + const strings = monthsByDays[30].map(date => date.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const date = Temporal.Now.plainDateISO(); + const percent = date.dayOfYear / date.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} + +{ + const date = Temporal.PlainDate.from("1900-01-01"); + date.monthsInYear; // => 12 +} + +{ + // Is this year a leap year? + const date = Temporal.Now.plainDateISO(); + date.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + date.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const date = Temporal.PlainDate.from("2006-01-24"); + // What's the first day of this month? + date.with({ day: 1 }); // => 2006-01-01 + // What's the last day of the next month? + const nextMonthDate = date.add({ months: 1 }); + nextMonthDate.with({ day: nextMonthDate.daysInMonth }); // => 2006-02-28 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24[u-ca=japanese]"); + date.withCalendar("iso8601"); // => 2006-08-24 +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.add({ years: 20, months: 4 }); // => 2026-12-24 + + date = Temporal.PlainDate.from("2019-01-31"); + date.add({ months: 1 }); // => 2019-02-28 + date.add({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + let date: Temporal.PlainDate; + + date = Temporal.PlainDate.from("2006-08-24"); + date.subtract({ years: 20, months: 4 }); // => 1986-04-24 + + date = Temporal.PlainDate.from("2019-03-31"); + date.subtract({ months: 1 }); // => 2019-02-28 + date.subtract({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + earlier.until(later); // => P4543D + earlier.until(later, { largestUnit: "year" }); // => P12Y5M7D + later.until(earlier, { largestUnit: "year" }); // => -P12Y5M7D + + // If you really need to calculate the difference between two Dates in + // hours, you can eliminate the ambiguity by explicitly choosing the + // point in time from which you want to reckon the difference. For + // example, using noon: + const noon = Temporal.PlainTime.from("12:00"); + earlier.toPlainDateTime(noon).until(later.toPlainDateTime(noon), { largestUnit: "hour" }); + // => PT109032H + + const newyear = Temporal.PlainDate.from("2020-01-01"); + newyear.until("2020-01-15", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S + newyear.until("2020-01-16", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT0S (mid-month dates rounded down to match `Temporal.PlainDateTime` behavior) + newyear.until("2020-01-17", { smallestUnit: "month", roundingMode: "halfExpand" }); + // => PT1M +} + +{ + const earlier = Temporal.PlainDate.from("2006-08-24"); + const later = Temporal.PlainDate.from("2019-01-31"); + later.since(earlier); // => P4543D +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + const other = Temporal.PlainDate.from("2019-01-31"); + date.equals(other); // => false + date.equals(date); // => true +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toString(); // => '2006-08-24' +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toLocaleString(); // example output: 8/24/2006 + date.toLocaleString("de-DE"); // example output: '24.8.2006' + date.toLocaleString("de-DE", { weekday: "long" }); // => 'Donnerstag' + date.toLocaleString("en-US-u-nu-fullwide"); // => '8/24/2006' +} + +{ + const plainDate = Temporal.PlainDate.from("2006-08-24"); + const plainTime = Temporal.PlainTime.from("15:23:30.003"); + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles", plainTime }); + // => 2006-08-24T15:23:30.003-07:00[America/Los_Angeles] + plainDate.toZonedDateTime({ timeZone: "America/Los_Angeles" }); + // => 2006-08-24T00:00:00-07:00[America/Los_Angeles] +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + const time = Temporal.PlainTime.from("15:23:30.003"); + date.toPlainDateTime(time); // => 2006-08-24T15:23:30.003 + date.toPlainDateTime(); // => 2006-08-24T00:00:00 +} + +{ + const date = Temporal.PlainDate.from("2006-08-24"); + date.toPlainYearMonth(); // => 2006-08 + date.toPlainMonthDay(); // => 08-24 +} + +{ + // Leet hour + const time = new Temporal.PlainTime(13, 37); // => 13:37:00 +} + +{ + let time: Temporal.PlainTime; + + time = Temporal.PlainTime.from("03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("032430"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30"); // => 03:24:30 + time = Temporal.PlainTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 03:24:30 + // (same as above; time zone is ignored) + time === Temporal.PlainTime.from(time); // => false + + time = Temporal.PlainTime.from({ + hour: 19, + minute: 39, + second: 9, + millisecond: 68, + microsecond: 346, + nanosecond: 205, + }); // => 19:39:09.068346205 + time = Temporal.PlainTime.from({ hour: 19, minute: 39, second: 9 }); // => 19:39:09 + time = Temporal.PlainTime.from(Temporal.PlainDateTime.from("2020-02-15T19:39:09")); + // => 19:39:09 + // (same as above; Temporal.PlainDateTime has hour, minute, etc. properties) + + // Different overflow modes + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "constrain" }); + // => 15:59:00 + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "constrain" }); + // => 15:00:00 + time = Temporal.PlainTime.from({ hour: 15, minute: 60 }, { overflow: "reject" }); + // => throws + time = Temporal.PlainTime.from({ hour: 15, minute: -1 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainTime.from("03:24"); + const two = Temporal.PlainTime.from("01:24"); + const three = Temporal.PlainTime.from("01:24:05"); + const sorted = [one, two, three].sort(Temporal.PlainTime.compare); + sorted.join(" "); // => '01:24:00 01:24:05 03:24:00' +} + +{ + // Backward transitions will repeat clock times + const zdtDst = Temporal.ZonedDateTime.from("2020-11-01T01:45-07:00[America/Los_Angeles]"); + const zdtStandard = Temporal.ZonedDateTime.from("2020-11-01T01:30-08:00[America/Los_Angeles]"); + // The "first" 1:45 (in Daylight Time) is earlier than the "second" 1:30 (in Standard Time) + Temporal.ZonedDateTime.compare(zdtDst, zdtStandard); // => -1 + // 1:45 is later than 1:30 when looking at a wall clock + Temporal.PlainTime.compare(zdtDst, zdtStandard); // => 1 + + // Forward transitions will skip clock times. Skipped times will be disambiguated. + const zdtBase = Temporal.ZonedDateTime.from("2020-03-08[America/Los_Angeles]"); + const timeSkipped = Temporal.PlainTime.from("02:30"); + const timeValid = Temporal.PlainTime.from("03:30"); + const zdtSkipped = zdtBase.withPlainTime(timeSkipped); + const zdtValid = zdtBase.withPlainTime(timeValid); + // The skipped time 2:30AM is disambiguated to 3:30AM, so the instants are equal + Temporal.ZonedDateTime.compare(zdtSkipped, zdtValid); // => 0 + // 2:30 is earlier than 3:30 on a wall clock + Temporal.PlainTime.compare(timeSkipped, timeValid); // => -1 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.hour; // => 19 + time.minute; // => 39 + time.second; // => 9 + time.millisecond; // => 68 + time.microsecond; // => 346 + time.nanosecond; // => 205 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + // What's the top of the next hour? + time.add({ hours: 1 }).with({ + minute: 0, + second: 0, + millisecond: 0, + microsecond: 0, + nanosecond: 0, + }); // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.add({ minutes: 5, nanoseconds: 800 }); // => 19:44:09.068347005 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.subtract({ minutes: 5, nanoseconds: 800 }); // => 19:34:09.068345405 +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.until(Temporal.PlainTime.from("22:39:09.068346205")); // => PT2H25M48.096948106S + time.until(Temporal.PlainTime.from("19:39:09.068346205")); // => -PT34M11.903051894S + + // Rounding, for example if you don't care about sub-seconds + time.until(Temporal.PlainTime.from("22:39:09.068346205"), { smallestUnit: "second" }); + // => PT2H25M48S +} + +{ + const time = Temporal.PlainTime.from("20:13:20.971398099"); + time.since(Temporal.PlainTime.from("19:39:09.068346205")); // => PT34M11.903051894S + time.since(Temporal.PlainTime.from("22:39:09.068346205")); // => -PT2H25M48.096948106S +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + + // Round to a particular unit + time.round({ smallestUnit: "hour" }); // => 20:00:00 + // Round to an increment of a unit, e.g. half an hour: + time.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 19:30:00 + // Round to the same increment but round up instead: + time.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "ceil" }); + // => 20:00:00 +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + const other = Temporal.PlainTime.from("20:13:20.971398099"); + time.equals(other); // => false + time.equals(time); // => true +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toString(); // => '19:39:09.068346205' + + time.toString({ smallestUnit: "minute" }); // => '19:39' + time.toString({ fractionalSecondDigits: 0 }); // => '19:39:09' + time.toString({ fractionalSecondDigits: 4 }); // => '19:39:09.0683' + time.toString({ fractionalSecondDigits: 5, roundingMode: "halfExpand" }); + // => '19:39:09.06835' +} + +{ + const time = Temporal.PlainTime.from("19:39:09.068346205"); + time.toLocaleString(); // example output: '7:39:09 PM' + time.toLocaleString("de-DE"); // example output: '19:39:09' + time.toLocaleString("de-DE", { timeZone: "Europe/Berlin" }); // => '19:39:09' + time.toLocaleString("en-US-u-nu-fullwide-hc-h24"); // => '19:39:09' +} + +{ + // Leet hour on pi day in 2020 + const datetime = new Temporal.PlainDateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37:00 +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30"); + dt = Temporal.PlainDateTime.from("19951207T032430"); + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30+01:00[Europe/Brussels]"); + // => 1995-12-07T03:24:30 + // same as above; time zone is ignored + dt === Temporal.PlainDateTime.from(dt); // => false + + dt = Temporal.PlainDateTime.from({ + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }); // => 1995-12-07T03:24:30.0000035 + dt = Temporal.PlainDateTime.from({ year: 1995, month: 12, day: 7 }); // => 1995-12-07T00:00:00 + dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from("1995-12-07T03:24:30")); + // => 1995-12-07T00:00:00 + // same as above; Temporal.PlainDate has year, month, and day properties + + dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: "hebrew" }); + // => 1995-12-07T03:24:30[u-ca=hebrew] + + // Different overflow modes + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); + // => 2001-12-01T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "constrain" }); + // => 2001-01-31T00:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "constrain" }); + // => 2001-01-01T23:00:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "constrain" }); + // => 2001-01-01T00:59:00 + dt = Temporal.PlainDateTime.from({ year: 2001, month: 13, day: 1 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 32 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, hour: 25 }, { overflow: "reject" }); + // => throws + dt = Temporal.PlainDateTime.from({ year: 2001, month: 1, day: 1, minute: 60 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainDateTime.from("1995-12-07T03:24"); + const two = Temporal.PlainDateTime.from("1995-12-07T01:24"); + const three = Temporal.PlainDateTime.from("2015-12-07T01:24"); + const sorted = [one, two, three].sort(Temporal.PlainDateTime.compare); + sorted.join(" "); + // => '1995-12-07T01:24:00 1995-12-07T03:24:00 2015-12-07T01:24:00' +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.year; // => 1995 + dt.month; // => 12 + dt.monthCode; // => 'M12' + dt.day; // => 7 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 + + dt = Temporal.PlainDateTime.from("2019-02-23T03:24:30.000003500[u-ca=hebrew]"); + dt.year; // => 5779 + dt.month; // => 6 + dt.monthCode; // => 'M05L' + dt.day; // => 18 + dt.hour; // => 3 + dt.minute; // => 24 + dt.second; // => 30 + dt.millisecond; // => 0 + dt.microsecond; // => 3 + dt.nanosecond; // => 500 +} + +{ + const date = Temporal.PlainDateTime.from("-000015-01-01T12:30[u-ca=gregory]"); + date.era; + // => 'bce' + date.eraYear; + // => 16 + date.year; + // => -15 +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"][dt.dayOfWeek - 1]; // => 'THU' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + // ISO ordinal date + console.log(dt.year, dt.dayOfYear); // => '1995 341' +} + +{ + const dt = Temporal.PlainDateTime.from("2022-01-01T03:24:30.000003500"); + // ISO week date + console.log(dt.yearOfWeek, dt.weekOfYear, dt.dayOfWeek); // => '2021 52 6' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.daysInWeek; // => 7 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const dt = Temporal.Now.plainDateTimeISO().with({ month }); + monthsByDays[dt.daysInMonth] = (monthsByDays[dt.daysInMonth] || []).concat(dt); + } + + const strings = monthsByDays[30].map(dt => dt.toLocaleString("en", { month: "long" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const dt = Temporal.Now.plainDateTimeISO(); + const percent = dt.dayOfYear / dt.daysInYear; + `The year is ${percent.toLocaleString("en", { style: "percent" })} over!`; + // example output: "The year is 10% over!" +} + +{ + const dt = Temporal.PlainDate.from("1900-01-01T12:00"); + dt.monthsInYear; // => 12 +} + +{ + // Is this year a leap year? + const dt = Temporal.Now.plainDateTimeISO(); + dt.inLeapYear; // example output: true + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + dt.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.with({ year: 2015, second: 31 }); // => 2015-12-07T03:24:31.0000035 +} + +{ + const dt = Temporal.PlainDateTime.from("2015-12-07T03:24:30.000003500"); + dt.withPlainTime({ hour: 10 }); // => 2015-12-07T10:00:00 + const time = Temporal.PlainTime.from("11:22"); + dt.withPlainTime(time); // => 2015-12-07T11:22:00 + dt.withPlainTime("12:34"); // => 2015-12-07T12:34:00 + + // easier for chaining + dt.add({ days: 2, hours: 22 }).withPlainTime("00:00"); // => 2015-12-10T00:00:00 +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500[u-ca=japanese]"); + dt.withCalendar("iso8601"); // => 1995-12-07T03:24:30.0000035 +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.add({ years: 20, months: 4, nanoseconds: 500 }); // => 2016-04-07T03:24:30.000004 + + dt = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt.add({ months: 1 }); // => 2019-02-28T15:30:00 + dt.add({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + let dt: Temporal.PlainDateTime; + + dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.subtract({ years: 20, months: 4, nanoseconds: 500 }); // => 1975-08-07T03:24:30.000003 + + dt = Temporal.PlainDateTime.from("2019-03-31T15:30"); + dt.subtract({ months: 1 }); // => 2019-02-28T15:30:00 + dt.subtract({ months: 1 }, { overflow: "reject" }); // => throws +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.until(dt2); + // => P8456DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "year" }); + // => P23Y1M24DT12H5M29.9999965S + dt2.until(dt1, { largestUnit: "year" }); + // => -P23Y1M24DT12H5M29.9999965S + dt1.until(dt2, { largestUnit: "nanosecond" }); + // => PT730641929.999996544S + // (precision lost) + + // Rounding, for example if you don't care about sub-seconds + dt1.until(dt2, { smallestUnit: "second" }); + // => P8456DT12H5M29S + + // Months and years can be different lengths + const [jan1, feb1, mar1] = [1, 2, 3].map(month => Temporal.PlainDateTime.from({ year: 2020, month, day: 1 })); + jan1.until(feb1); // => P31D + jan1.until(feb1, { largestUnit: "month" }); // => P1M + feb1.until(mar1); // => P29D + feb1.until(mar1, { largestUnit: "month" }); // => P1M + jan1.until(mar1); // => P60D +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt2.since(dt1); // => P8456DT12H5M29.9999965S +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + + // Round to a particular unit + dt.round({ smallestUnit: "hour" }); // => 1995-12-07T03:00:00 + // Round to an increment of a unit, e.g. half an hour: + dt.round({ roundingIncrement: 30, smallestUnit: "minute" }); + // => 1995-12-07T03:30:00 + // Round to the same increment but round down instead: + dt.round({ roundingIncrement: 30, smallestUnit: "minute", roundingMode: "floor" }); + // => 1995-12-07T03:00:00 +} + +{ + const dt1 = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + const dt2 = Temporal.PlainDateTime.from("2019-01-31T15:30"); + dt1.equals(dt2); // => false + dt1.equals(dt1); // => true +} + +{ + const dt = Temporal.PlainDateTime.from({ + year: 1999, + month: 12, + day: 31, + hour: 23, + minute: 59, + second: 59, + millisecond: 999, + microsecond: 999, + nanosecond: 999, + }); + dt.toString(); // => '1999-12-31T23:59:59.999999999' + + dt.toString({ smallestUnit: "minute" }); // => '1999-12-31T23:59' + dt.toString({ fractionalSecondDigits: 0 }); // => '1999-12-31T23:59:59' + dt.toString({ fractionalSecondDigits: 4 }); // => '1999-12-31T23:59:59.9999' + dt.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => '2000-01-01T00:00:00.00000000' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toLocaleString(); // example output: 1995-12-07, 3:24:30 a.m. + dt.toLocaleString("de-DE"); // example output: 7.12.1995, 03:24:30 + dt.toLocaleString("de-DE", { timeZone: "Europe/Berlin", weekday: "long" }); // => 'Donnerstag' + dt.toLocaleString("en-US-u-nu-fullwide-hc-h12"); // => '12/7/1995, 3:24:30 AM' +} + +{ + const dt = Temporal.PlainDateTime.from("1995-12-07T03:24:30.000003500"); + dt.toPlainDate(); // => 1995-12-07 + dt.toPlainTime(); // => 03:24:30.0000035 + dt.toPlainDate().toPlainYearMonth(); // => 1995-12 + dt.toPlainDate().toPlainMonthDay(); // => 12-07 +} + +{ + // The June 2019 meeting + const ym = new Temporal.PlainYearMonth(2019, 6); + // => 2019-06 +} + +{ + let ym: Temporal.PlainYearMonth; + + ym = Temporal.PlainYearMonth.from("2019-06"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27"); // => 2019-06 + ym = Temporal.PlainYearMonth.from("2019-06-24T15:43:27+01:00[Europe/Brussels]"); + // => 2019-06 + ym === Temporal.PlainYearMonth.from(ym); // => false + + ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6 }); // => 2019-06 + ym = Temporal.PlainYearMonth.from(Temporal.PlainDate.from("2019-06-24")); + // => 2019-06 + // (same as above; Temporal.PlainDate has year and month properties) + + // Different overflow modes + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "constrain" }); + // => 2001-12 + ym = Temporal.PlainYearMonth.from({ year: 2001, month: 13 }, { overflow: "reject" }); + // => throws +} + +{ + const one = Temporal.PlainYearMonth.from("2006-08"); + const two = Temporal.PlainYearMonth.from("2015-07"); + const three = Temporal.PlainYearMonth.from("1930-02"); + const sorted = [one, two, three].sort(Temporal.PlainYearMonth.compare); + sorted.join(" "); // => '1930-02 2006-08 2015-07' +} + +{ + let ym: Temporal.PlainYearMonth; + + ym = Temporal.PlainYearMonth.from("2019-06"); + ym.year; // => 2019 + ym.month; // => 6 + ym.monthCode; // => 'M06' + + ym = Temporal.PlainYearMonth.from("2019-02-23[u-ca=hebrew]"); + ym.year; // => 5779 + ym.month; // => 6 + ym.monthCode; // => 'M05L' +} + +{ + const ym = Temporal.PlainYearMonth.from("-000015-01-01[u-ca=gregory]"); + ym.era; + // => 'bce' + ym.eraYear; + // => 16 + ym.year; + // => -15 +} + +{ + // Attempt to write some mnemonic poetry + const monthsByDays: Record = {}; + for (let month = 1; month <= 12; month++) { + const ym = Temporal.PlainYearMonth.from({ year: 2020, calendar: "iso8601", month }); + monthsByDays[ym.daysInMonth] = (monthsByDays[ym.daysInMonth] || []).concat(ym); + } + + const strings = monthsByDays[30].map(ym => ym.toLocaleString("en", { month: "long", calendar: "iso8601" })); + // Shuffle to improve poem as determined empirically + strings.unshift(strings.pop()!); + const format = new Intl.ListFormat("en"); + const poem = `Thirty days hath ${format.format(strings)}`; + + console.log(poem); +} + +{ + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar: "iso8601" }); + const percent = ym.daysInMonth / ym.daysInYear; + `${ym.toLocaleString("en", { month: "long", year: "numeric", calendar: "iso8601" })} was ${percent.toLocaleString("en", { style: "percent" })} of the year!`; + // => 'June 2019 was 8% of the year!' +} + +{ + const ym = Temporal.PlainYearMonth.from("1900-01"); + ym.monthsInYear; // => 12 +} + +{ + // Was June 2019 in a leap year? + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.inLeapYear; // => false + // Is 2100 a leap year? (no, because it's divisible by 100 and not 400) + ym.with({ year: 2100 }).inLeapYear; // => false +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + // Get December of that year + ym.with({ month: 12 }); // => 2019-12 +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.add({ years: 20, months: 4 }); // => 2039-10 +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.subtract({ years: 20, months: 4 }); // => 1999-02 +} + +{ + const ym = Temporal.PlainYearMonth.from("2006-08"); + const other = Temporal.PlainYearMonth.from("2019-06"); + ym.until(other); // => P12Y10M + ym.until(other, { largestUnit: "month" }); // => P154M + other.until(ym, { largestUnit: "month" }); // => -P154M + + // If you really need to calculate the difference between two YearMonths + // in days, you can eliminate the ambiguity by explicitly choosing the + // day of the month (and if applicable, the time of that day) from which + // you want to reckon the difference. For example, using the first of + // the month to calculate a number of days: + ym.toPlainDate({ day: 1 }).until(other.toPlainDate({ day: 1 }), { largestUnit: "day" }); // => P4687D +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.since(other); // => P12Y10M +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + const other = Temporal.PlainYearMonth.from("2006-08"); + ym.equals(other); // => false + ym.equals(ym); // => true +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toString(); // => '2019-06' +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const ym = Temporal.PlainYearMonth.from({ year: 2019, month: 6, calendar }); + ym.toLocaleString(); // example output: '6/2019' + // Same as above, but explicitly specifying the calendar: + ym.toLocaleString(undefined, { calendar }); + + ym.toLocaleString("de-DE", { calendar }); // example output: '6.2019' + ym.toLocaleString("de-DE", { month: "long", year: "numeric", calendar }); // => 'Juni 2019' + ym.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '6/2019' +} + +{ + const ym = Temporal.PlainYearMonth.from("2019-06"); + ym.toPlainDate({ day: 24 }); // => 2019-06-24 +} + +{ + let md: Temporal.PlainMonthDay; + + // Pi day + md = new Temporal.PlainMonthDay(3, 14); // => 03-14 + // Leap day + md = new Temporal.PlainMonthDay(2, 29); // => 02-29 +} + +{ + let md: Temporal.PlainMonthDay; + + md = Temporal.PlainMonthDay.from("08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("0824"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27"); // => 08-24 + md = Temporal.PlainMonthDay.from("2006-08-24T15:43:27+01:00[Europe/Brussels]"); + // => 08-24 + md === Temporal.PlainMonthDay.from(md); // => false + + md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24 }); // => 08-24 + md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from("2006-08-24")); + // => 08-24 + // (same as above; Temporal.PlainDate has month and day properties) + + // Different overflow modes + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "constrain" }); + // => 12-01 + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "constrain" }); + // => 01-31 + md = Temporal.PlainMonthDay.from({ month: 13, day: 1, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 1, day: 32, year: 2000 }, { overflow: "reject" }); + // => throws + md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow: "reject" }); + // => throws (this year is not a leap year in the ISO 8601 calendar) + + // non-ISO calendars + md = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 15, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: "hebrew" }); + // => 1970-02-21[u-ca=hebrew] + /* WRONG */ md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: "hebrew" }); + // => throws (either year or monthCode is required) + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // undefined + // (month property is not present in this type; use monthCode instead) +} + +{ + let md: Temporal.PlainMonthDay; + + md = Temporal.PlainMonthDay.from("08-24"); + md.monthCode; // => 'M08' + md.day; // => 24 + md.month; // => undefined + // (no `month` property; use `monthCode` instead) + + md = Temporal.PlainMonthDay.from("2019-02-20[u-ca=hebrew]"); + md.monthCode; // => 'M05L' + md.day; // => 15 + md.month; // => undefined + // (no `month` property; use `monthCode` instead) +} + +{ + const md = Temporal.PlainMonthDay.from("11-15"); + // What's the last day of that month? + md.with({ day: 31 }); // => 11-30 + Temporal.PlainMonthDay.from("02-01").with({ day: 31 }); // => 02-29 +} + +{ + const md1 = Temporal.PlainMonthDay.from("02-28"); + const md2 = Temporal.PlainMonthDay.from("02-29"); + md1.equals(md2); // => false + md1.equals("02-29"); // => false + md1.equals({ monthCode: "M02", day: 29 }); // => false + md2.equals(md2); // => true + md2.equals("02-29"); // => true + md2.equals({ monthCode: "M02", day: 29 }); // => true +} + +{ + const md = Temporal.PlainMonthDay.from("08-24"); + md.toString(); // => '08-24' +} + +{ + const { calendar } = new Intl.DateTimeFormat().resolvedOptions(); + const md = Temporal.PlainMonthDay.from({ monthCode: "M08", day: 24, calendar }); + md.toLocaleString(); // example output: '8/24' + // Same as above, but explicitly specifying the calendar: + md.toLocaleString(undefined, { calendar }); // example output: '8/24' + + md.toLocaleString("de-DE", { calendar }); // => '24.8.' + md.toLocaleString("de-DE", { month: "long", day: "numeric", calendar }); // => '24. August' + md.toLocaleString(`en-US-u-nu-fullwide-ca-${calendar}`); // => '8/24' +} + +{ + const md = Temporal.PlainMonthDay.from({ + calendar: "japanese", + monthCode: "M01", + day: 1, + }); + + const date = md.toPlainDate({ era: "reiwa", eraYear: 2 }); // => 2020-01-01[u-ca=japanese] +} + +{ + new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); // => P1Y2M3W4DT5H6M7.987654321S + new Temporal.Duration(0, 0, 0, 40); // => P40D + new Temporal.Duration(undefined, undefined, undefined, 40); // => P40D + new Temporal.Duration(); // => PT0S +} + +{ + let d: Temporal.Duration; + + d = Temporal.Duration.from({ years: 1, days: 1 }); // => P1Y1D + d = Temporal.Duration.from({ days: -2, hours: -12 }); // => -P2DT12H + + Temporal.Duration.from(d) === d; // => false + + d = Temporal.Duration.from("P1Y1D"); // => P1Y1D + d = Temporal.Duration.from("-P2DT12H"); // => -P2DT12H + d = Temporal.Duration.from("P0D"); // => PT0S +} + +{ + const one = Temporal.Duration.from({ hours: 79, minutes: 10 }); + const two = Temporal.Duration.from({ days: 3, hours: 7, seconds: 630 }); + const three = Temporal.Duration.from({ days: 3, hours: 6, minutes: 50 }); + const sorted1 = [one, two, three].sort(Temporal.Duration.compare); + sorted1.join(" "); + // => 'P3DT6H50M PT79H10M P3DT7H630S' + + // Sorting relative to a date, taking DST changes into account: + const relativeTo = Temporal.ZonedDateTime.from("2020-11-01T00:00-07:00[America/Los_Angeles]"); + const sorted2 = [one, two, three].sort((one, two) => Temporal.Duration.compare(one, two, { relativeTo })); + sorted2.join(" "); + // => 'PT79H10M P3DT6H50M P3DT7H630S' +} + +{ + const d = Temporal.Duration.from("P1Y2M3W4DT5H6M7.987654321S"); + d.years; // => 1 + d.months; // => 2 + d.weeks; // => 3 + d.days; // => 4 + d.hours; // => 5 + d.minutes; // => 6 + d.seconds; // => 7 + d.milliseconds; // => 987 + d.microseconds; // => 654 + d.nanoseconds; // => 321 +} + +{ + let d: Temporal.Duration; + + d = Temporal.Duration.from("PT0S"); + d.blank; // => true + + d = Temporal.Duration.from({ days: 0, hours: 0, minutes: 0 }); + d.blank; // => true +} + +{ + let duration: Temporal.Duration; + + duration = Temporal.Duration.from({ months: 50, days: 50, hours: 50, minutes: 100 }); + // Perform a balance operation using additional ISO 8601 calendar rules: + let { years, months } = duration; + years += Math.floor(months / 12); + months %= 12; + duration = duration.with({ years, months }); + // => P4Y2M50DT50H100M +} + +{ + const hour = Temporal.Duration.from("PT1H"); + hour.add({ minutes: 30 }); // => PT1H30M + + // Examples of balancing: + const one = Temporal.Duration.from({ hours: 1, minutes: 30 }); + const two = Temporal.Duration.from({ hours: 2, minutes: 45 }); + const result = one.add(two); // => PT4H15M + + // Example of adding calendar units + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 16 }); + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2000-12-01"); + startDate1.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P3M4D + + const startDate2 = Temporal.PlainDate.from("2001-01-01"); + startDate2.add(oneAndAHalfMonth).add(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P3M1D +} + +{ + const hourAndAHalf = Temporal.Duration.from("PT1H30M"); + hourAndAHalf.subtract({ hours: 1 }); // => PT30M + + const one = Temporal.Duration.from({ minutes: 180 }); + const two = Temporal.Duration.from({ seconds: 30 }); + one.subtract(two); // => PT179M30S + one.subtract(two).round({ largestUnit: "hour" }); // => PT2H59M30S + + // Example of subtracting calendar units; cannot be subtracted using + // subtract() because units need to be converted + const threeMonths = Temporal.Duration.from({ months: 3 }); + const oneAndAHalfMonth = Temporal.Duration.from({ months: 1, days: 15 }); + + // To convert units, use arithmetic relative to a start date: + const startDate1 = Temporal.PlainDate.from("2001-01-01"); + startDate1.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate1, { largestUnit: "months" }); // => P1M13D + + const startDate2 = Temporal.PlainDate.from("2001-02-01"); + startDate2.add(threeMonths).subtract(oneAndAHalfMonth) + .since(startDate2, { largestUnit: "months" }); // => P1M16D +} + +{ + const d = Temporal.Duration.from("P1Y2M3DT4H5M6.987654321S"); + d.sign; // 1 + d.negated(); // -P1Y2M3DT4H5M6.987654321S + d.negated().sign; // -1 +} + +{ + const d = Temporal.Duration.from("-PT8H30M"); + d.abs(); // PT8H30M +} + +{ + let d: Temporal.Duration; + + // Balance a duration as far as possible without knowing a starting point + d = Temporal.Duration.from({ minutes: 130 }); + d.round({ largestUnit: "day" }); // => PT2H10M + + // Round to the nearest unit + d = Temporal.Duration.from({ minutes: 10, seconds: 52 }); + d.round({ smallestUnit: "minute" }); // => PT11M + d.round({ smallestUnit: "minute", roundingMode: "trunc" }); // => PT10M + + // How many seconds in a multi-unit duration? + d = Temporal.Duration.from("PT2H34M18S"); + d.round({ largestUnit: "second" }).seconds; // => 9258 + + // Normalize, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.round({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + largestUnit: "year", + }); // => P114DT21H + // (one hour longer because DST skipped an hour) + d.round({ + relativeTo: "2020-01-01", + largestUnit: "year", + }); // => P114DT20H + // (one hour shorter if ignoring DST) + + // Normalize days into months or years + d = Temporal.Duration.from({ days: 190 }); + const refDate = Temporal.PlainDate.from("2020-01-01"); + d.round({ relativeTo: refDate, largestUnit: "year" }); // => P6M8D + + // Same, but in a different calendar system + d.round({ + relativeTo: refDate.withCalendar("hebrew"), + largestUnit: "year", + }); // => P6M13D + + // Round a duration up to the next 5-minute billing period + d = Temporal.Duration.from({ minutes: 6 }); + d.round({ + smallestUnit: "minute", + roundingIncrement: 5, + roundingMode: "ceil", + }); // => PT10M + + // How many full 3-month quarters of this year, are in this duration? + d = Temporal.Duration.from({ months: 10, days: 15 }); + d = d.round({ + smallestUnit: "month", + roundingIncrement: 3, + roundingMode: "trunc", + relativeTo: Temporal.Now.plainDateISO(), + }); + const quarters = d.months / 3; + quarters; // => 3 +} + +{ + let d: Temporal.Duration; + + // How many seconds in 130 hours and 20 minutes? + d = Temporal.Duration.from({ hours: 130, minutes: 20 }); + d.total({ unit: "second" }); // => 469200 + + // How many 24-hour days is 123456789 seconds? + d = Temporal.Duration.from("PT123456789S"); + d.total({ unit: "day" }); // 1428.8980208333332 + + // Find totals in months, with and without taking DST into account + d = Temporal.Duration.from({ hours: 2756 }); + d.total({ + relativeTo: "2020-01-01T00:00+01:00[Europe/Rome]", + unit: "month", + }); // => 3.7958333333333334 + d.total({ + unit: "month", + relativeTo: "2020-01-01", + }); // => 3.7944444444444443 +} + +{ + let d: Temporal.Duration; + + d = Temporal.Duration.from({ years: 1, days: 1 }); + d.toString(); // => P1Y1D + d = Temporal.Duration.from({ years: -1, days: -1 }); + d.toString(); // => -P1Y1D + d = Temporal.Duration.from({ milliseconds: 1000 }); + d.toString(); // => PT1S + + // The output format always balances units under 1 s, even if the + // underlying Temporal.Duration object doesn't. + const nobal = Temporal.Duration.from({ milliseconds: 3500 }); + console.log(`${nobal}`, nobal.seconds, nobal.milliseconds); // => 'PT3.5S 0 3500' + const bal = nobal.round({ largestUnit: "year" }); // balance through round + console.log(`${bal}`, bal.seconds, bal.milliseconds); // => 'PT3.5S 3 500' + + d = Temporal.Duration.from("PT59.999999999S"); + d.toString({ smallestUnit: "second" }); // => PT59S + d.toString({ fractionalSecondDigits: 0 }); // => PT59S + d.toString({ fractionalSecondDigits: 4 }); // => PT59.9999S + d.toString({ fractionalSecondDigits: 8, roundingMode: "halfExpand" }); + // => PT60.00000000S +} + +{ + const d = Temporal.Duration.from("P1DT6H30M"); + d.toLocaleString(); // example output: '1 day 6 hours 30 minutes' + d.toLocaleString("de-DE"); // example output: '1 Tag 6 Stunden 30 Minuten' + d.toLocaleString("en-US", { days: "short", hours: "numeric" }); // example output: '1 day 6 hours' +} + +{ + Temporal.Now.instant(); // get the current system exact time + Temporal.Now.timeZoneId(); // get the current system time zone + Temporal.Now.zonedDateTimeISO(); // get the current date and wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateISO(); // get the current date in the system time zone and ISO-8601 calendar + Temporal.Now.plainTimeISO(); // get the current wall-clock time in the system time zone and ISO-8601 calendar + Temporal.Now.plainDateTimeISO(); // same as above, but return the DateTime in the ISO-8601 calendar +}