Skip to content

Commit

Permalink
Remove support for nested Temporal time zone property bags
Browse files Browse the repository at this point in the history
Previously, "nested" time zone property bags were unwrapped up to one
level. That is, this object:
{
  timeZone: {
     // ...Temporal.TimeZone methods
  }
}
would not be considered to implement the TimeZone protocol, but would have
its timeZone property used instead, if it were passed to an API that
required a TimeZone protocol object.

These nested property bags are no longer supported. Discussion:
tc39/proposal-temporal#2104 (comment)

Corresponding normative PR:
tc39/proposal-temporal#2485
  • Loading branch information
ptomato committed Apr 10, 2023
1 parent 8866567 commit 24def91
Show file tree
Hide file tree
Showing 205 changed files with 262 additions and 1,810 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
"has options.relativeTo.timeZone.timeZone",
"get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
"get options.relativeTo.timeZone.getOffsetNanosecondsFor",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ features: [Temporal]

let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone");
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "bare date-time string is not a time zone");

// The following are all valid strings so should not throw:

Expand All @@ -30,5 +29,4 @@ assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(
"2021-08-19T1730-0700[UTC]",
].forEach((timeZone) => {
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ features: [Temporal]

let timeZone = "2016-12-31T23:59:60+00:00[UTC]";

// A string with a leap second is a valid ISO string, so the following two
// operations should not throw
// A string with a leap second is a valid ISO string, so the following
// operation should not throw

Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });

timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]";
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "leap second in time zone name not valid");
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "leap second in time zone name not valid (nested property)");
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,4 @@ invalidStrings.forEach((timeZone) => {
() => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
"reject minus zero as extended year"
);
assert.throws(
RangeError,
() => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }),
"reject minus zero as extended year (nested property)"
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const rangeErrorTests = [

for (const [timeZone, description] of rangeErrorTests) {
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
}

const typeErrorTests = [
Expand All @@ -30,8 +29,4 @@ const typeErrorTests = [

for (const [timeZone, description] of typeErrorTests) {
assert.throws(TypeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
assert.throws(TypeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
}

const timeZone = undefined;
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// ToRelativeTemporalObject again
"has options.relativeTo.timeZone.timeZone",
// InterpretISODateTimeOffset
"get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const instance = new Temporal.Duration(1);

let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone");
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "bare date-time string is not a time zone");

// The following are all valid strings so should not throw:

Expand All @@ -32,5 +31,4 @@ assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativ
"2021-08-19T1730-0700[UTC]",
].forEach((timeZone) => {
instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ features: [Temporal]
const instance = new Temporal.Duration(1);
let timeZone = "2016-12-31T23:59:60+00:00[UTC]";

// A string with a leap second is a valid ISO string, so the following two
// operations should not throw
// A string with a leap second is a valid ISO string, so the following
// operation should not throw

instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });

timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]";
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "leap second in time zone name not valid");
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "leap second in time zone name not valid (nested property)");
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,4 @@ invalidStrings.forEach((timeZone) => {
() => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
"reject minus zero as extended year"
);
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }),
"reject minus zero as extended year (nested property)"
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const rangeErrorTests = [

for (const [timeZone, description] of rangeErrorTests) {
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
}

const typeErrorTests = [
Expand All @@ -32,8 +31,4 @@ const typeErrorTests = [

for (const [timeZone, description] of typeErrorTests) {
assert.throws(TypeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
assert.throws(TypeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
}

const timeZone = undefined;
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ const expectedOpsForZonedRelativeTo = [
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
"has options.relativeTo.timeZone.timeZone",
// InterpretISODateTimeOffset
"get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const instance = new Temporal.Duration(1);

let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone");
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "bare date-time string is not a time zone");

// The following are all valid strings so should not throw:

Expand All @@ -32,5 +31,4 @@ assert.throws(RangeError, () => instance.round({ largestUnit: "months", relative
"2021-08-19T1730-0700[UTC]",
].forEach((timeZone) => {
instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ features: [Temporal]
const instance = new Temporal.Duration(1);
let timeZone = "2016-12-31T23:59:60+00:00[UTC]";

// A string with a leap second is a valid ISO string, so the following two
// operations should not throw
// A string with a leap second is a valid ISO string, so the following
// operation should not throw

instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });

timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]";
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "leap second in time zone name not valid");
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "leap second in time zone name not valid (nested property)");
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,4 @@ invalidStrings.forEach((timeZone) => {
() => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
"reject minus zero as extended year"
);
assert.throws(
RangeError,
() => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }),
"reject minus zero as extended year (nested property)"
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const rangeErrorTests = [

for (const [timeZone, description] of rangeErrorTests) {
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
}

const typeErrorTests = [
Expand All @@ -32,8 +31,4 @@ const typeErrorTests = [

for (const [timeZone, description] of typeErrorTests) {
assert.throws(TypeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
assert.throws(TypeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
}

const timeZone = undefined;
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// ToRelativeTemporalObject again
"has options.relativeTo.timeZone.timeZone",
// InterpretISODateTimeOffset
"get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const instance = new Temporal.Duration(1);

let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone");
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "bare date-time string is not a time zone");

// The following are all valid strings so should not throw:

Expand All @@ -32,5 +31,4 @@ assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { re
"2021-08-19T1730-0700[UTC]",
].forEach((timeZone) => {
instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ features: [Temporal]
const instance = new Temporal.Duration(1);
let timeZone = "2016-12-31T23:59:60+00:00[UTC]";

// A string with a leap second is a valid ISO string, so the following two
// operations should not throw
// A string with a leap second is a valid ISO string, so the following
// operation should not throw

instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } });
instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } });

timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]";
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "leap second in time zone name not valid");
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), "leap second in time zone name not valid (nested property)");
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,4 @@ invalidStrings.forEach((timeZone) => {
() => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
"reject minus zero as extended year"
);
assert.throws(
RangeError,
() => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }),
"reject minus zero as extended year (nested property)"
);
});
Loading

0 comments on commit 24def91

Please sign in to comment.