Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test more ISO strings with sub-minute offsets #3892

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,34 @@ 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");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ 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");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ 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");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ 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");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ const instance = new Temporal.Duration(1);
let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ const instance = new Temporal.Instant(0n);
let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.toString({ timeZone }), "bare date-time string is not a time zone");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.toString({ timeZone }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.toString({ timeZone }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

timeZone = "2021-08-19T17:30Z";
const result1 = instance.toString({ timeZone });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ const instance = new Temporal.Instant(0n);
let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), "bare date-time string is not a time zone");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

timeZone = "2021-08-19T17:30Z";
const result1 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ const instance = new Temporal.Instant(0n);
let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => instance.toZonedDateTimeISO(timeZone), "bare date-time string is not a time zone");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => instance.toZonedDateTimeISO(timeZone), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => instance.toZonedDateTimeISO(timeZone),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

timeZone = "2021-08-19T17:30Z";
const result1 = instance.toZonedDateTimeISO(timeZone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,34 @@ features: [Temporal]
let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "bare date-time string is not a time zone");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => Temporal.Now.plainDate("iso8601", timeZone),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,34 @@ features: [Temporal]
let timeZone = "2021-08-19T17:30";
assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), "bare date-time string is not a time zone");

timeZone = "2021-08-19T17:30-07:00:01";
assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), "ISO string sub-minute offset is not OK as time zone");
[
"2021-08-19T17:30-07:00:01",
"2021-08-19T17:30-07:00:00",
"2021-08-19T17:30-07:00:00.1",
"2021-08-19T17:30-07:00:00.0",
"2021-08-19T17:30-07:00:00.01",
"2021-08-19T17:30-07:00:00.00",
"2021-08-19T17:30-07:00:00.001",
"2021-08-19T17:30-07:00:00.000",
"2021-08-19T17:30-07:00:00.0001",
"2021-08-19T17:30-07:00:00.0000",
"2021-08-19T17:30-07:00:00.00001",
"2021-08-19T17:30-07:00:00.00000",
"2021-08-19T17:30-07:00:00.000001",
"2021-08-19T17:30-07:00:00.000000",
"2021-08-19T17:30-07:00:00.0000001",
"2021-08-19T17:30-07:00:00.0000000",
"2021-08-19T17:30-07:00:00.00000001",
"2021-08-19T17:30-07:00:00.00000000",
"2021-08-19T17:30-07:00:00.000000001",
"2021-08-19T17:30-07:00:00.000000000",
].forEach((timeZone) => {
assert.throws(
RangeError,
() => Temporal.Now.plainDateISO(timeZone),
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
);
});

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

Expand Down
Loading