From 133921b2dc5e0c853a442951d954cdccb77ba155 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 8 May 2024 16:44:52 -0700 Subject: [PATCH] Normative: Replace TimeZone transition methods with ZonedDateTime methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TimeZone.p.getNextTransition → ZonedDateTime.p.nextTransition TimeZone.p.getPreviousTransition → ZonedDateTime.p.previousTransition This is one step towards removing Temporal.TimeZone. The functionality of querying UTC offset transition remains, but is moved to ZonedDateTime. See: #2826 Co-Authored-By: Richard Gibson --- docs/cookbook.md | 6 +- docs/cookbook/all.mjs | 2 +- ...tantOfNearestOffsetTransitionToInstant.mjs | 34 ---------- .../getInstantWithLocalTimeInZone.mjs | 21 +++--- .../getNextOffsetTransitionFromExactTime.mjs | 33 ++++++++++ docs/timezone.md | 66 ------------------- docs/zoneddatetime.md | 38 +++++++++++ polyfill/index.d.ts | 10 +-- polyfill/lib/ecmascript.mjs | 5 ++ polyfill/lib/timezone.mjs | 30 --------- polyfill/lib/zoneddatetime.mjs | 28 ++++++++ spec/abstractops.html | 15 +++++ spec/timezone.html | 32 --------- spec/zoneddatetime.html | 29 ++++++++ 14 files changed, 168 insertions(+), 181 deletions(-) delete mode 100644 docs/cookbook/getInstantOfNearestOffsetTransitionToInstant.mjs create mode 100644 docs/cookbook/getNextOffsetTransitionFromExactTime.mjs diff --git a/docs/cookbook.md b/docs/cookbook.md index c1533c7cc9..8508e7725e 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -428,13 +428,13 @@ Take the difference between two `Temporal.Instant` instances as a `Temporal.Dura ``` -### Nearest offset transition in a time zone +### Next offset transition in a time zone -Map a `Temporal.Instant` instance and a `Temporal.TimeZone` object into a `Temporal.Instant` instance representing the nearest following exact time at which there is an offset transition in the time zone (e.g., for setting reminders). +Map a `Temporal.ZonedDateTime` instance into another `Temporal.ZonedDateTime` instance representing the nearest following exact time at which there is an offset transition in the time zone (e.g., for setting reminders). ```javascript -{{cookbook/getInstantOfNearestOffsetTransitionToInstant.mjs}} +{{cookbook/getNextOffsetTransitionFromExactTime.mjs}} ``` diff --git a/docs/cookbook/all.mjs b/docs/cookbook/all.mjs index 8eba33df05..452d1ccdbd 100644 --- a/docs/cookbook/all.mjs +++ b/docs/cookbook/all.mjs @@ -11,9 +11,9 @@ import './getCurrentDate.mjs'; import './getElapsedDurationSinceInstant.mjs'; import './getFirstTuesdayOfMonth.mjs'; import './getInstantBeforeOldRecord.mjs'; -import './getInstantOfNearestOffsetTransitionToInstant.mjs'; import './getInstantWithLocalTimeInZone.mjs'; import './getLocalizedArrival.mjs'; +import './getNextOffsetTransitionFromExactTime.mjs'; import './getParseableZonedStringAtInstant.mjs'; import './getSortedLocalDateTimes.mjs'; import './getTimeStamp.mjs'; diff --git a/docs/cookbook/getInstantOfNearestOffsetTransitionToInstant.mjs b/docs/cookbook/getInstantOfNearestOffsetTransitionToInstant.mjs deleted file mode 100644 index 4a7dbae7a5..0000000000 --- a/docs/cookbook/getInstantOfNearestOffsetTransitionToInstant.mjs +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Get the nearest following exact time that the given time zone transitions - * to another UTC offset, inclusive or exclusive. - * - * @param {Temporal.Instant} instant - Starting exact time to consider - * @param {Temporal.TimeZone} timeZone - Time zone to consider - * @param {boolean} inclusive - Include the start time, or not - * @returns {(Temporal.Instant|null)} - Next UTC offset transition, or null if - * none known at this time - */ -function getInstantOfNearestOffsetTransitionToInstant(instant, timeZone, inclusive) { - let nearest; - if (inclusive) { - // In case instant itself is the exact time of a transition: - nearest = timeZone.getNextTransition(instant.subtract({ nanoseconds: 1 })); - } else { - nearest = timeZone.getNextTransition(instant); - } - return nearest; -} - -const instant = Temporal.Instant.from('2019-04-16T21:01Z'); - -const nyc = Temporal.TimeZone.from('America/New_York'); -const nextTransition = getInstantOfNearestOffsetTransitionToInstant(instant, nyc, false); -assert.equal(nextTransition.toString(), '2019-11-03T06:00:00Z'); - -// Inclusive -const sameTransition = getInstantOfNearestOffsetTransitionToInstant(nextTransition, nyc, true); -assert.equal(sameTransition.toString(), nextTransition.toString()); - -// No known future DST transitions in a time zone -const regina = Temporal.TimeZone.from('America/Regina'); -assert.equal(getInstantOfNearestOffsetTransitionToInstant(instant, regina), null); diff --git a/docs/cookbook/getInstantWithLocalTimeInZone.mjs b/docs/cookbook/getInstantWithLocalTimeInZone.mjs index fecb31fd6a..96d9ff12c5 100644 --- a/docs/cookbook/getInstantWithLocalTimeInZone.mjs +++ b/docs/cookbook/getInstantWithLocalTimeInZone.mjs @@ -23,27 +23,26 @@ function getInstantWithLocalTimeInZone(dateTime, timeZone, disambiguation = 'earlier') { // Handle the built-in modes first if (['compatible', 'earlier', 'later', 'reject'].includes(disambiguation)) { - return timeZone.getInstantFor(dateTime, { disambiguation }); + return dateTime.toZonedDateTime(timeZone, { disambiguation }).toInstant(); } - const possible = timeZone.getPossibleInstantsFor(dateTime); + const zdts = ['earlier', 'later'].map((disambiguation) => dateTime.toZonedDateTime(timeZone, { disambiguation })); + const instants = zdts.map((zdt) => zdt.toInstant()).reduce((a, b) => (a.equals(b) ? [a] : [a, b])); // Return only possibility if no disambiguation needed - if (possible.length === 1) return possible[0]; + if (instants.length === 1) return instants[0]; switch (disambiguation) { case 'clipEarlier': - if (possible.length === 0) { - const before = timeZone.getInstantFor(dateTime, { disambiguation: 'earlier' }); - return timeZone.getNextTransition(before).subtract({ nanoseconds: 1 }); + if (zdts[0].toPlainDateTime().equals(dateTime)) { + return instants[0]; } - return possible[0]; + return zdts[0].getTimeZoneTransition('next').subtract({ nanoseconds: 1 }).toInstant(); case 'clipLater': - if (possible.length === 0) { - const before = timeZone.getInstantFor(dateTime, { disambiguation: 'earlier' }); - return timeZone.getNextTransition(before); + if (zdts[1].toPlainDateTime().equals(dateTime)) { + return instants[1]; } - return possible[possible.length - 1]; + return zdts[0].getTimeZoneTransition('next').toInstant(); } throw new RangeError(`invalid disambiguation ${disambiguation}`); } diff --git a/docs/cookbook/getNextOffsetTransitionFromExactTime.mjs b/docs/cookbook/getNextOffsetTransitionFromExactTime.mjs new file mode 100644 index 0000000000..49915d6e30 --- /dev/null +++ b/docs/cookbook/getNextOffsetTransitionFromExactTime.mjs @@ -0,0 +1,33 @@ +/** + * Get the nearest following exact time that the given time zone transitions + * to another UTC offset, inclusive or exclusive. + * + * @param {Temporal.ZonedDateTime} zonedDateTime - Starting exact time and time + * zone to consider + * @param {boolean} inclusive - Include the start time, or not + * @returns {(Temporal.ZonedDateTime|null)} - Next UTC offset transition, or + * null if none known at this time + */ +function getNextOffsetTransitionFromExactTime(zonedDateTime, inclusive) { + let nearest; + if (inclusive) { + // In case instant itself is the exact time of a transition: + nearest = zonedDateTime.subtract({ nanoseconds: 1 }).getTimeZoneTransition('next'); + } else { + nearest = zonedDateTime.getTimeZoneTransition('next'); + } + return nearest; +} + +const nycTime = Temporal.ZonedDateTime.from('2019-04-16T21:01Z[America/New_York]'); + +const nextTransition = getNextOffsetTransitionFromExactTime(nycTime, false); +assert.equal(nextTransition.toString(), '2019-11-03T01:00:00-05:00[America/New_York]'); + +// Inclusive +const sameTransition = getNextOffsetTransitionFromExactTime(nextTransition, true); +assert.equal(sameTransition.toString(), nextTransition.toString()); + +// No known future DST transitions in a time zone +const reginaTime = Temporal.ZonedDateTime.from('2019-04-16T21:01Z[America/Regina]'); +assert.equal(getNextOffsetTransitionFromExactTime(reginaTime), null); diff --git a/docs/timezone.md b/docs/timezone.md index 738d70099f..f0c02f0fa3 100644 --- a/docs/timezone.md +++ b/docs/timezone.md @@ -446,72 +446,6 @@ See [Resolving ambiguity](./ambiguity.md) for usage examples and a more complete Although this method is useful for implementing a custom time zone or custom disambiguation behavior, but otherwise `getInstantFor()` should be used instead, because it is more convenient, because it's compatible with the behavior of other methods and libraries, and because it always returns a single value. For example, during "skipped" clock time like the hour after DST starts in the spring, `getPossibleInstantsFor()` returns an empty array while `getInstantFor()` returns a `Temporal.Instant`. -### timeZone.**getNextTransition**(_startingPoint_: Temporal.Instant | string) : Temporal.Instant - -**Parameters:** - -- `startingPoint` (`Temporal.Instant` or value convertible to one): Time after which to find the next UTC offset transition. - -**Returns:** A `Temporal.Instant` object representing the next UTC offset transition in this time zone, or `null` if no transitions later than `startingPoint` could be found. - -This method is used to calculate a possible future UTC offset transition after `startingPoint` for this time zone. -A "transition" is a point in time where the UTC offset of a time zone changes, for example when Daylight Saving Time starts or stops. -Transitions can also be caused by other political changes like a country permanently changing the UTC offset of its time zone. - -The returned `Temporal.Instant` will represent the first nanosecond where the new UTC offset is used, not the last nanosecond where the previous UTC offset is used. - -When no more transitions are expected, this method will return `null`. -Some time zones (e.g., `Etc/GMT+5` or `-05:00`) have no offset transitions and will return `null` for all values of `startingPoint`. - -If `instant` is not a `Temporal.Instant` object, then it will be converted to one as if it were passed to `Temporal.Instant.from()`. - -When subclassing `Temporal.TimeZone`, this method should be overridden if the time zone changes offsets. -Single-offset time zones can use the default implementation which returns `null`. - -Example usage: - -```javascript -// How long until the next offset change from now, in the current location? -tz = Temporal.Now.timeZone(); -now = Temporal.Now.instant(); -nextTransition = tz.getNextTransition(now); -duration = nextTransition.since(now); -duration.toLocaleString(); // output will vary -``` - -### timeZone.**getPreviousTransition**(_startingPoint_: Temporal.Instant | string) : Temporal.Instant - -**Parameters:** - -- `startingPoint` (`Temporal.Instant` or value convertible to one): Time before which to find the previous UTC offset transition. - -**Returns:** A `Temporal.Instant` object representing the previous UTC offset transition in this time zone, or `null` if no transitions earlier than `startingPoint` could be found. - -This method is used to calculate a possible past UTC offset transition before `startingPoint` for this time zone. -A "transition" is a point in time where the UTC offset of a time zone changes, for example when Daylight Saving Time starts or stops. -Transitions can also be caused by other political changes like a country permanently changing the UTC offset of its time zone. - -The returned `Temporal.Instant` will represent the first nanosecond where the new UTC offset is used, not the last nanosecond where the previous UTC offset is used. - -When no previous transitions exist, this method will return `null`. -Some time zones (e.g., `Etc/GMT+5` or `-05:00`) have no offset transitions and will return `null` for all values of `startingPoint`. - -If `instant` is not a `Temporal.Instant` object, then it will be converted to one as if it were passed to `Temporal.Instant.from()`. - -When subclassing `Temporal.TimeZone`, this method should be overridden if the time zone changes offsets. -Single-offset time zones can use the default implementation which returns `null`. - -Example usage: - -```javascript -// How long until the previous offset change from now, in the current location? -tz = Temporal.Now.timeZone(); -now = Temporal.Now.instant(); -previousTransition = tz.getPreviousTransition(now); -duration = now.since(previousTransition); -duration.toLocaleString(); // output will vary -``` - ### timeZone.**toString**() : string **Returns:** The string given by `timeZone.id`. diff --git a/docs/zoneddatetime.md b/docs/zoneddatetime.md index 8597013e52..d4455fad5e 100644 --- a/docs/zoneddatetime.md +++ b/docs/zoneddatetime.md @@ -1155,6 +1155,44 @@ zdt = Temporal.ZonedDateTime.from('2018-11-04T12:00-02:00[America/Sao_Paulo]').s ``` +### zonedDateTime.**getTimeZoneTransition**(direction: string | object) : Temporal.ZonedDateTime | null + +**Parameters:** + +- `direction` (string | object): A required string or object to control the operation. + A string parameter is treated the same as an object whose `direction` property value is that string. + If an object is passed, the following properties are recognized: + - `direction` (required string): The direction in which to search for the closest UTC offset transition. + Valid values are `'next'` and `'previous'`. + +**Returns:** A `Temporal.ZonedDateTime` object representing the following UTC offset transition in `zonedDateTime`'s time zone in the given direction, or `null` if no transitions farther than `zonedDateTime` could be found. + +This method is used to calculate the closest past or future UTC offset transition from `zonedDateTime` for its time zone. +A "transition" is a point in time where the UTC offset of a time zone changes, for example when Daylight Saving Time starts or stops. +Transitions can also be caused by other political changes like a country permanently changing the UTC offset of its time zone. + +The returned `Temporal.ZonedDateTime` will represent the first nanosecond where the newer UTC offset is used, not the last nanosecond where the previous UTC offset is used. + +When no more transitions are expected in the given directoin, this method will return `null`. +Some time zones (e.g., `Etc/GMT+5` or `-05:00`) have no offset transitions. +If `zonedDateTime` has one of these time zones, this method will always return `null`. + +Example usage: + +```javascript +// How long until the next offset change from now, in the current location? +tz = Temporal.Now.timeZoneId(); +now = Temporal.Now.zonedDateTimeISO(tz); +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? +previousTransition = now.getTimeZoneTransition('previous'); +duration = now.since(previousTransition); +duration.toLocaleString(); // output will vary +``` + ### zonedDateTime.**equals**(_other_: Temporal.ZonedDateTime) : boolean **Parameters:** diff --git a/polyfill/index.d.ts b/polyfill/index.d.ts index ee268ae73b..5bf578aeb8 100644 --- a/polyfill/index.d.ts +++ b/polyfill/index.d.ts @@ -489,6 +489,11 @@ export namespace Temporal { relativeTo?: Temporal.ZonedDateTime | Temporal.PlainDateTime | ZonedDateTimeLike | PlainDateTimeLike | string; } + /** + * Options to control behaviour of `ZonedDateTime.prototype.getTimeZoneTransition()` + */ + export type TransitionDirection = 'next' | 'previous' | { direction: 'next' | 'previous' }; + export type DurationLike = { years?: number; months?: number; @@ -1094,8 +1099,6 @@ export namespace Temporal { dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string, options?: ToInstantOptions ): Temporal.Instant; - getNextTransition?(startingPoint: Temporal.Instant | string): Temporal.Instant | null; - getPreviousTransition?(startingPoint: Temporal.Instant | string): Temporal.Instant | null; getPossibleInstantsFor(dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string): Temporal.Instant[]; toString?(): string; toJSON?(): string; @@ -1132,8 +1135,6 @@ export namespace Temporal { dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string, options?: ToInstantOptions ): Temporal.Instant; - getNextTransition(startingPoint: Temporal.Instant | string): Temporal.Instant | null; - getPreviousTransition(startingPoint: Temporal.Instant | string): Temporal.Instant | null; getPossibleInstantsFor(dateTime: Temporal.PlainDateTime | PlainDateTimeLike | string): Temporal.Instant[]; toString(): string; toJSON(): string; @@ -1300,6 +1301,7 @@ export namespace Temporal { roundTo: RoundTo<'day' | 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'> ): Temporal.ZonedDateTime; startOfDay(): Temporal.ZonedDateTime; + getTimeZoneTransition(direction: TransitionDirection): Temporal.ZonedDateTime | null; toInstant(): Temporal.Instant; toPlainDateTime(): Temporal.PlainDateTime; toPlainDate(): Temporal.PlainDate; diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index 1ef55a84c5..78b11c3518 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -908,6 +908,10 @@ export function GetTemporalShowOffsetOption(options) { return GetOption(options, 'offset', ['auto', 'never'], 'auto'); } +export function GetDirectionOption(options) { + return GetOption(options, 'direction', ['next', 'previous'], REQUIRED); +} + export function GetRoundingIncrementOption(options) { let increment = options.roundingIncrement; if (increment === undefined) return 1; @@ -5558,6 +5562,7 @@ export function GetOption(options, property, allowedValues, fallback) { } return value; } + if (fallback === REQUIRED) throw new RangeError(`${property} option is required`); return fallback; } diff --git a/polyfill/lib/timezone.mjs b/polyfill/lib/timezone.mjs index 1a675bf8c0..ca5b511716 100644 --- a/polyfill/lib/timezone.mjs +++ b/polyfill/lib/timezone.mjs @@ -120,36 +120,6 @@ export class TimeZone { ); return possibleEpochNs.map((ns) => new Instant(ns)); } - getNextTransition(startingPoint) { - if (!ES.IsTemporalTimeZone(this)) throw new TypeError('invalid receiver'); - startingPoint = ES.ToTemporalInstant(startingPoint); - const id = GetSlot(this, TIMEZONE_ID); - - // Offset time zones or UTC have no transitions - if (ES.IsOffsetTimeZoneIdentifier(id) || id === 'UTC') { - return null; - } - - let epochNanoseconds = GetSlot(startingPoint, EPOCHNANOSECONDS); - const Instant = GetIntrinsic('%Temporal.Instant%'); - epochNanoseconds = ES.GetNamedTimeZoneNextTransition(id, epochNanoseconds); - return epochNanoseconds === null ? null : new Instant(epochNanoseconds); - } - getPreviousTransition(startingPoint) { - if (!ES.IsTemporalTimeZone(this)) throw new TypeError('invalid receiver'); - startingPoint = ES.ToTemporalInstant(startingPoint); - const id = GetSlot(this, TIMEZONE_ID); - - // Offset time zones or UTC have no transitions - if (ES.IsOffsetTimeZoneIdentifier(id) || id === 'UTC') { - return null; - } - - let epochNanoseconds = GetSlot(startingPoint, EPOCHNANOSECONDS); - const Instant = GetIntrinsic('%Temporal.Instant%'); - epochNanoseconds = ES.GetNamedTimeZonePreviousTransition(id, epochNanoseconds); - return epochNanoseconds === null ? null : new Instant(epochNanoseconds); - } toString() { if (!ES.IsTemporalTimeZone(this)) throw new TypeError('invalid receiver'); return GetSlot(this, TIMEZONE_ID); diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index 8174f8531a..04a3596ca4 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -540,6 +540,34 @@ export class ZonedDateTime { const instant = ES.GetInstantFor(timeZoneRec, dtStart, 'compatible'); return ES.CreateTemporalZonedDateTime(GetSlot(instant, EPOCHNANOSECONDS), timeZoneRec.receiver, calendar); } + getTimeZoneTransition(directionParam) { + if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); + const timeZone = GetSlot(this, TIME_ZONE); + const id = ES.ToTemporalTimeZoneIdentifier(timeZone); + + if (directionParam === undefined) throw new TypeError('options parameter is required'); + if (ES.Type(directionParam) === 'String') { + const stringParam = directionParam; + directionParam = ObjectCreate(null); + directionParam.direction = stringParam; + } else { + directionParam = ES.GetOptionsObject(directionParam); + } + const direction = ES.GetDirectionOption(directionParam); + if (direction === undefined) throw new TypeError('direction option is required'); + + // Offset time zones or UTC have no transitions + if (ES.IsOffsetTimeZoneIdentifier(id) || id === 'UTC') { + return null; + } + + const thisEpochNanoseconds = GetSlot(this, EPOCHNANOSECONDS); + const epochNanoseconds = + direction === 'next' + ? ES.GetNamedTimeZoneNextTransition(id, thisEpochNanoseconds) + : ES.GetNamedTimeZonePreviousTransition(id, thisEpochNanoseconds); + return epochNanoseconds === null ? null : new ZonedDateTime(epochNanoseconds, timeZone, GetSlot(this, CALENDAR)); + } toInstant() { if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); const TemporalInstant = GetIntrinsic('%Temporal.Instant%'); diff --git a/spec/abstractops.html b/spec/abstractops.html index 46f3fee30c..aaf66b2a5e 100644 --- a/spec/abstractops.html +++ b/spec/abstractops.html @@ -527,6 +527,21 @@

+ +

+ GetDirectionOption ( + _options_: an Object, + ): either a normal completion containing either *"next"* or *"previous"*, or a throw completion +

+
+
description
+
It fetches and validates the *"direction"* property from _options_, throwing if absent.
+
+ + 1. Return ? GetOption(_options_, *"direction"*, ~string~, « *"next"*, *"previous"* », ~required~). + +
+

GetRoundingIncrementOption ( diff --git a/spec/timezone.html b/spec/timezone.html index c29591624b..96ddff163d 100644 --- a/spec/timezone.html +++ b/spec/timezone.html @@ -201,38 +201,6 @@

Temporal.TimeZone.prototype.getPossibleInstantsFor ( _dateTime_ )

- -

Temporal.TimeZone.prototype.getNextTransition ( _startingPoint_ )

-

- This method performs the following steps when called: -

- - 1. Let _timeZone_ be the *this* value. - 1. Perform ? RequireInternalSlot(_timeZone_, [[InitializedTemporalTimeZone]]). - 1. Set _startingPoint_ to ? ToTemporalInstant(_startingPoint_). - 1. If _timeZone_.[[OffsetMinutes]] is not ~empty~, return *null*. - 1. Let _transition_ be GetNamedTimeZoneNextTransition(_timeZone_.[[Identifier]], _startingPoint_.[[Nanoseconds]]). - 1. If _transition_ is *null*, return *null*. - 1. Return ! CreateTemporalInstant(_transition_). - -
- - -

Temporal.TimeZone.prototype.getPreviousTransition ( _startingPoint_ )

-

- This method performs the following steps when called: -

- - 1. Let _timeZone_ be the *this* value. - 1. Perform ? RequireInternalSlot(_timeZone_, [[InitializedTemporalTimeZone]]). - 1. Set _startingPoint_ to ? ToTemporalInstant(_startingPoint_). - 1. If _timeZone_.[[OffsetMinutes]] is not ~empty~, return *null*. - 1. Let _transition_ be GetNamedTimeZonePreviousTransition(_timeZone_.[[Identifier]], _startingPoint_.[[Nanoseconds]]). - 1. If _transition_ is *null*, return *null*. - 1. Return ! CreateTemporalInstant(_transition_). - -
-

Temporal.TimeZone.prototype.toString ( )

diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html index 2b068d6205..846a381459 100644 --- a/spec/zoneddatetime.html +++ b/spec/zoneddatetime.html @@ -876,6 +876,35 @@

Temporal.ZonedDateTime.prototype.startOfDay ( )

+ +

Temporal.ZonedDateTime.prototype.getTimeZoneTransition ( _directionParam_ )

+

+ This method performs the following steps when called: +

+ + 1. Let _zonedDateTime_ be the *this* value. + 1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]). + 1. Let _timeZone_ be _zonedDateTime_.[[TimeZone]]. + 1. Let _id_ be ? ToTemporalTimeZoneIdentifier(_timeZone_). + 1. If _directionParam_ is *undefined*, throw a *TypeError* exception. + 1. If _directionParam_ is a String, then + 1. Let _paramString_ be _directionParam_. + 1. Set _directionParam_ to OrdinaryObjectCreate(*null*). + 1. Perform ! CreateDataPropertyOrThrow(_directionParam_, *"direction"*, _paramString_). + 1. Else, + 1. Set _directionParam_ to ? GetOptionsObject(_directionParam_). + 1. Let _direction_ be ? GetDirectionOption(_directionParam_). + 1. If IsOffsetTimeZoneIdentifier(_id_) is *true* or _id_ is *"UTC"*, return *null*. + 1. If _direction_ is *"next"*, then + 1. Let _transition_ be GetNamedTimeZoneNextTransition(_id_, _zonedDateTime_.[[Nanoseconds]]). + 1. Else, + 1. Assert: _direction_ is *"previous"*. + 1. Let _transition_ be GetNamedTimeZonePreviousTransition(_id_, _zonedDateTime_.[[Nanoseconds]]). + 1. If _transition_ is *null*, return *null*. + 1. Return ! CreateTemporalZonedDateTime(_transition_, _timeZone_, _zonedDateTime_.[[Calendar]]). + +
+

Temporal.ZonedDateTime.prototype.toInstant ( )