Temporal: Replace TemporalHelpers.specificOffsetTimeZone with offset strings

This commit is contained in:
Philip Chimento 2024-06-04 13:05:56 +02:00 committed by Ms2ger
parent 0a1cb1307f
commit 27bc974287
24 changed files with 75 additions and 139 deletions

View File

@ -1662,41 +1662,6 @@ var TemporalHelpers = {
});
},
/*
* specificOffsetTimeZone():
*
* This returns an instance of a custom time zone class, which returns a
* specific custom value from its getOffsetNanosecondsFrom() method. This is
* for the purpose of testing the validation of what this method returns.
*
* It also returns an empty array from getPossibleInstantsFor(), so as to
* trigger calls to getOffsetNanosecondsFor() when used from the
* BuiltinTimeZoneGetInstantFor operation.
*/
specificOffsetTimeZone(offsetValue) {
class SpecificOffsetTimeZone extends Temporal.TimeZone {
constructor(offsetValue) {
super("UTC");
this._offsetValue = offsetValue;
}
getOffsetNanosecondsFor() {
return this._offsetValue;
}
getPossibleInstantsFor(dt) {
if (typeof this._offsetValue !== 'number' || Math.abs(this._offsetValue) >= 86400e9 || isNaN(this._offsetValue)) return [];
const zdt = dt.toZonedDateTime("UTC").add({ nanoseconds: -this._offsetValue });
return [zdt.toInstant()];
}
get id() {
return this.getOffsetStringFor(new Temporal.Instant(0n));
}
}
return new SpecificOffsetTimeZone(offsetValue);
},
/*
* timeZoneObserver:
* A custom calendar that behaves exactly like the UTC time zone but tracks

View File

@ -35,10 +35,9 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const date = new Temporal.PlainDate(2000, 5, 2);
const pdt = date.toPlainDateTime(datetime);
TemporalHelpers.assertPlainDateTime(pdt, 2000, 5, "M05", 2, 1, 1, 1, 1, 0, 999);
TemporalHelpers.assertPlainDateTime(pdt, 2000, 5, "M05", 2, 0, 59, 1, 1, 1, 1);

View File

@ -28,19 +28,16 @@ info: |
ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]).
sec-temporal.plaindate.prototype.tozoneddatetime step 6.a:
a. Set _temporalTime_ to ? ToTemporalTime(_temporalTime_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const otherTimeZone = new Temporal.TimeZone("UTC"); // should not be used to convert datetime to PlainTime
const date = new Temporal.PlainDate(2000, 5, 2);
const zdt = date.toZonedDateTime({ timeZone: otherTimeZone, plainTime: datetime });
const zdt = date.toZonedDateTime({ timeZone: "UTC", plainTime: datetime });
assert.sameValue(zdt.microsecond, 0);
assert.sameValue(zdt.nanosecond, 999);
assert.sameValue(zdt.hour, 0);
assert.sameValue(zdt.minute, 59);

View File

@ -35,9 +35,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const pdt = Temporal.PlainDateTime.from(datetime);
TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 1, 1, 1, 1, 0, 999);
TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 0, 59, 1, 1, 1, 1);

View File

@ -28,14 +28,12 @@ info: |
ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]).
sec-temporal.plaindatetime.prototype.until step 3:
3. Set _other_ ? ToTemporalDateTime(_other_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
assert(new Temporal.PlainDateTime(1970, 1, 1, 1, 1, 1, 1, 0, 999).equals(datetime));
assert(new Temporal.PlainDateTime(1970, 1, 1, 0, 59, 1, 1, 1, 1).equals(datetime));

View File

@ -35,9 +35,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const diff = new Temporal.PlainDateTime(1970, 1, 1).since(datetime);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, -1, -1, -1, -1, 0, -999);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, -59, -1, -1, -1, -1);

View File

@ -35,9 +35,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const diff = new Temporal.PlainDateTime(1970, 1, 1).until(datetime);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 1, 1, 1, 1, 0, 999);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, 59, 1, 1, 1, 1);

View File

@ -35,10 +35,9 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const pdt = new Temporal.PlainDateTime(2000, 5, 2);
const newpdt = pdt.withPlainTime(datetime);
TemporalHelpers.assertPlainDateTime(newpdt, 2000, 5, "M05", 2, 1, 1, 1, 1, 0, 999);
TemporalHelpers.assertPlainDateTime(newpdt, 2000, 5, "M05", 2, 0, 59, 1, 1, 1, 1);

View File

@ -35,9 +35,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const time = Temporal.PlainTime.from(datetime);
TemporalHelpers.assertPlainTime(time, 1, 1, 1, 1, 0, 999);
TemporalHelpers.assertPlainTime(time, 0, 59, 1, 1, 1, 1);

View File

@ -28,14 +28,12 @@ info: |
ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]).
sec-temporal.plaintime.prototype.equals step 3:
3. Set _other_ to ? ToTemporalTime(_other_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
assert(new Temporal.PlainTime(1, 1, 1, 1, 0, 999).equals(datetime));
assert(new Temporal.PlainTime(0, 59, 1, 1, 1, 1).equals(datetime));

View File

@ -35,9 +35,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const diff = new Temporal.PlainTime().since(datetime);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, -1, -1, -1, -1, 0, -999);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, -59, -1, -1, -1, -1);

View File

@ -35,9 +35,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const diff = new Temporal.PlainTime().until(datetime);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 1, 1, 1, 1, 0, 999);
TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, 59, 1, 1, 1, 1);

View File

@ -24,20 +24,18 @@ info: |
3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_).
sec-get-temporal.zoneddatetime.prototype.day step 6:
6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(86400_000_000_001n, tz);
const datetime = new Temporal.ZonedDateTime(86400_000_000_001n, "-00:02");
assert.sameValue(datetime.day, 1);
assert.sameValue(datetime.hour, 23);
assert.sameValue(datetime.minute, 59);
assert.sameValue(datetime.second, 59);
assert.sameValue(datetime.millisecond, 999);
assert.sameValue(datetime.microsecond, 999);
assert.sameValue(datetime.nanosecond, 999);
assert.sameValue(datetime.minute, 58);
assert.sameValue(datetime.second, 0);
assert.sameValue(datetime.millisecond, 0);
assert.sameValue(datetime.microsecond, 0);
assert.sameValue(datetime.nanosecond, 1);

View File

@ -31,10 +31,13 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// ZonedDateTime
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1001n, tz);
const datetime = new Temporal.ZonedDateTime(1001n, "-00:02");
const fields = datetime.getISOFields();
assert.sameValue(fields.isoMicrosecond, 0);
assert.sameValue(fields.isoNanosecond, 999);
assert.sameValue(fields.isoHour, 23);
assert.sameValue(fields.isoMinute, 58);
assert.sameValue(fields.isoSecond, 0);
assert.sameValue(fields.isoMillisecond, 0);
assert.sameValue(fields.isoMicrosecond, 1);
assert.sameValue(fields.isoNanosecond, 1);

View File

@ -22,19 +22,17 @@ info: |
3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_).
sec-get-temporal.zoneddatetime.prototype.hour step 6:
6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3600_000_000_001n, tz);
const datetime = new Temporal.ZonedDateTime(3600_000_000_001n, "-00:02");
assert.sameValue(datetime.hour, 0);
assert.sameValue(datetime.minute, 59);
assert.sameValue(datetime.second, 59);
assert.sameValue(datetime.millisecond, 999);
assert.sameValue(datetime.microsecond, 999);
assert.sameValue(datetime.nanosecond, 999);
assert.sameValue(datetime.minute, 58);
assert.sameValue(datetime.second, 0);
assert.sameValue(datetime.millisecond, 0);
assert.sameValue(datetime.microsecond, 0);
assert.sameValue(datetime.nanosecond, 1);

View File

@ -14,15 +14,14 @@ info: |
3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_).
sec-get-temporal.zoneddatetime.prototype.microsecond step 6:
6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1001n, tz);
const datetime = new Temporal.ZonedDateTime(1001n, "-00:02");
assert.sameValue(datetime.microsecond, 0);
assert.sameValue(datetime.nanosecond, 999);
assert.sameValue(datetime.minute, 58);
assert.sameValue(datetime.microsecond, 1);
assert.sameValue(datetime.nanosecond, 1);

View File

@ -16,16 +16,15 @@ info: |
3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_).
sec-get-temporal.zoneddatetime.prototype.millisecond step 6:
6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1_000_001n, tz);
const datetime = new Temporal.ZonedDateTime(1_000_001n, "-00:02");
assert.sameValue(datetime.millisecond, 0);
assert.sameValue(datetime.microsecond, 999);
assert.sameValue(datetime.nanosecond, 999);
assert.sameValue(datetime.minute, 58);
assert.sameValue(datetime.millisecond, 1);
assert.sameValue(datetime.microsecond, 0);
assert.sameValue(datetime.nanosecond, 1);

View File

@ -22,18 +22,16 @@ info: |
3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_).
sec-get-temporal.zoneddatetime.prototype.minute step 6:
6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(60_000_000_001n, tz);
const datetime = new Temporal.ZonedDateTime(60_000_000_001n, "-00:02");
assert.sameValue(datetime.minute, 0);
assert.sameValue(datetime.second, 59);
assert.sameValue(datetime.millisecond, 999);
assert.sameValue(datetime.microsecond, 999);
assert.sameValue(datetime.nanosecond, 999);
assert.sameValue(datetime.minute, 59);
assert.sameValue(datetime.second, 0);
assert.sameValue(datetime.millisecond, 0);
assert.sameValue(datetime.microsecond, 0);
assert.sameValue(datetime.nanosecond, 1);

View File

@ -18,17 +18,16 @@ info: |
3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_).
sec-get-temporal.zoneddatetime.prototype.second step 6:
6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1_000_000_001n, tz);
const datetime = new Temporal.ZonedDateTime(1_000_000_001n, "-00:02");
assert.sameValue(datetime.second, 0);
assert.sameValue(datetime.millisecond, 999);
assert.sameValue(datetime.microsecond, 999);
assert.sameValue(datetime.nanosecond, 999);
assert.sameValue(datetime.minute, 58);
assert.sameValue(datetime.second, 1);
assert.sameValue(datetime.millisecond, 0);
assert.sameValue(datetime.microsecond, 0);
assert.sameValue(datetime.nanosecond, 1);

View File

@ -26,16 +26,14 @@ info: |
9. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _isoCalendar_).
sec-get-temporal.zoneddatetime.prototype.tojson step 3:
3. Return ? TemporalZonedDateTimeToString(_zonedDateTime_, *"auto"*, *"auto"*, *"auto"*, *"auto"*).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// ZonedDateTime
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1001n, tz);
const datetime = new Temporal.ZonedDateTime(1001n, "-00:02");
const jsonString = datetime.toJSON();
assert.sameValue(jsonString, "1970-01-01T00:00:00.000000999+00:00[-00:00:00.000000002]");
assert.sameValue(jsonString, "1969-12-31T23:58:00.000001001-00:02[-00:02]");

View File

@ -31,9 +31,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1001n, tz);
const datetime = new Temporal.ZonedDateTime(1001n, "-00:02");
const pdt = datetime.toPlainDateTime();
TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 999);
TemporalHelpers.assertPlainDateTime(pdt, 1969, 12, "M12", 31, 23, 58, 0, 0, 1, 1);

View File

@ -31,9 +31,8 @@ features: [Temporal]
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1001n, tz);
const datetime = new Temporal.ZonedDateTime(1001n, "-00:02");
const time = datetime.toPlainTime();
TemporalHelpers.assertPlainTime(time, 0, 0, 0, 0, 0, 999);
TemporalHelpers.assertPlainTime(time, 23, 58, 0, 0, 1, 1);

View File

@ -26,16 +26,14 @@ info: |
9. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _isoCalendar_).
sec-get-temporal.zoneddatetime.prototype.tostring step 9:
9. Return ? TemporalZonedDateTimeToString(_zonedDateTime_, _precision_.[[Precision]], _showCalendar_, _showTimeZone_, _showOffset_, _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// ZonedDateTime
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(1001n, tz);
const datetime = new Temporal.ZonedDateTime(1001n, "-00:02");
const isoString = datetime.toString();
assert.sameValue(isoString, "1970-01-01T00:00:00.000000999+00:00[-00:00:00.000000002]");
assert.sameValue(isoString, "1969-12-31T23:58:00.000001001-00:02[-00:02]");

View File

@ -28,18 +28,16 @@ info: |
ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]).
sec-temporal.zoneddatetime.prototype.withplaintime step 4.a:
a. Let _plainTime_ be ? ToTemporalTime(_plainTimeLike_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// This code path is encountered if the time zone offset is negative and its
// absolute value in nanoseconds is greater than the nanosecond field of the
// exact time's epoch parts
const tz = TemporalHelpers.specificOffsetTimeZone(-2);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz);
const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02");
const zdt = new Temporal.ZonedDateTime(86400_000_000_000n, "UTC"); // UTC should not be used to convert datetime -> PlainTime
const newzdt = zdt.withPlainTime(datetime);
assert.sameValue(newzdt.microsecond, 0);
assert.sameValue(newzdt.nanosecond, 999);
assert.sameValue(newzdt.hour, 0);
assert.sameValue(newzdt.minute, 59);