mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:17:34 +00:00
LibJS: Implement Temporal.Now.plainDateTime()
This commit is contained in:
parent
f2a2e8e13c
commit
0bb19fc51c
4 changed files with 46 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.Now.plainDateTime).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const plainDateTime = Temporal.Now.plainDateTime(calendar);
|
||||
expect(plainDateTime).toBeInstanceOf(Temporal.PlainDateTime);
|
||||
expect(plainDateTime.calendar).toBe(calendar);
|
||||
});
|
||||
|
||||
test("custom time zone", () => {
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return 86400000000000;
|
||||
},
|
||||
};
|
||||
const plainDateTime = Temporal.Now.plainDateTime(calendar);
|
||||
const plainDateTimeWithOffset = Temporal.Now.plainDateTime(calendar, timeZone);
|
||||
// Yes, this will fail if a day, month, or year change happens between the above two lines :^)
|
||||
// FIXME: enable these once the getters are implemented
|
||||
// expect(plainDateTimeWithOffset.year).toBe(plainDateTime.year);
|
||||
// expect(plainDateTimeWithOffset.month).toBe(plainDateTime.month);
|
||||
// expect(plainDateTimeWithOffset.day).toBe(plainDateTime.day + 1);
|
||||
// expect(plainDateTimeWithOffset.hour).not.toBe(plainDateTime.hour);
|
||||
// expect(plainDateTimeWithOffset.minute).not.toBe(plainDateTime.minute);
|
||||
// expect(plainDateTimeWithOffset.second).not.toBe(plainDateTime.second);
|
||||
// expect(plainDateTimeWithOffset.millisecond).not.toBe(plainDateTime.millisecond);
|
||||
// microsecond, and nanosecond not checked here as they could easily be the same for both
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue