LibJS+LibUnicode: Support ambiguous time zone transitions
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-arm64, macos-15) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

For example, time zone transitions can result in repeated or skipped
wall times. Temporal wants us to handle these transitions.
This commit is contained in:
Timothy Flynn 2025-06-02 11:04:29 -04:00 committed by Shannon Booth
commit 8145572180
Notes: github-actions[bot] 2025-06-02 21:10:26 +00:00
4 changed files with 92 additions and 12 deletions

View file

@ -68,7 +68,7 @@ describe("correct behavior", () => {
expect(result).toBe(-1);
});
test("sub-minute time zone offset", () => {
test("sub-minute time zone offset (unambiguous time zone transition)", () => {
const duration1 = new Temporal.Duration(0, 0, 0, 31);
const duration2 = new Temporal.Duration(0, 1);
@ -82,6 +82,26 @@ describe("correct behavior", () => {
});
expect(result).toBe(0);
});
test("sub-minute time zone offset (ambiguous time zone transition)", () => {
const duration1 = new Temporal.Duration(0, 0, 0, 0, 24);
const duration2 = new Temporal.Duration(0, 0, 0, 1);
let result = Temporal.Duration.compare(duration1, duration2, {
relativeTo: "1952-10-15T23:59:59-11:19:40[Pacific/Niue]",
});
expect(result).toBe(-1);
result = Temporal.Duration.compare(duration1, duration2, {
relativeTo: "1952-10-15T23:59:59-11:20[Pacific/Niue]",
});
expect(result).toBe(-1);
result = Temporal.Duration.compare(duration1, duration2, {
relativeTo: "1952-10-15T23:59:59-11:20:00[Pacific/Niue]",
});
expect(result).toBe(0);
});
});
describe("errors", () => {
@ -148,7 +168,7 @@ describe("errors", () => {
);
});
test("sub-minute time zone offset mismatch", () => {
test("sub-minute time zone offset mismatch (unambiguous time zone transition)", () => {
const duration1 = new Temporal.Duration(0, 0, 0, 31);
const duration2 = new Temporal.Duration(0, 1);
@ -170,4 +190,18 @@ describe("errors", () => {
"Invalid offset for the provided date and time in the current time zone"
);
});
test("sub-minute time zone offset mismatch (ambiguous time zone transition)", () => {
const duration1 = new Temporal.Duration(0, 0, 0, 0, 24);
const duration2 = new Temporal.Duration(0, 0, 0, 1);
expect(() => {
Temporal.Duration.compare(duration1, duration2, {
relativeTo: "1952-10-15T23:59:59-11:19:50[Pacific/Niue]",
});
}).toThrowWithMessage(
RangeError,
"Invalid offset for the provided date and time in the current time zone"
);
});
});