mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:27:35 +00:00
LibJS: Implement Temporal.ZonedDateTime.prototype.offset
This commit is contained in:
parent
f937e9b966
commit
6c345c8107
6 changed files with 45 additions and 2 deletions
|
@ -0,0 +1,21 @@
|
|||
describe("correct behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
expect(zonedDateTime.offset).toBe("+00:00");
|
||||
});
|
||||
|
||||
test("custom offset", () => {
|
||||
const timeZone = new Temporal.TimeZone("+01:30");
|
||||
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
expect(zonedDateTime.offset).toBe("+01:30");
|
||||
});
|
||||
});
|
||||
|
||||
test("errors", () => {
|
||||
test("this value must be a Temporal.ZonedDateTime object", () => {
|
||||
expect(() => {
|
||||
Reflect.get(Temporal.ZonedDateTime.prototype, "offset", "foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue