1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:58:11 +00:00

LibJS: Implement Date's string constructor

... by calling Date.parse().

With this, dates on http://45.33.8.238/ and
http://45.33.8.238/linux/summary.html are correctly converted to local
time :^)
This commit is contained in:
Nico Weber 2020-08-21 13:24:52 -04:00 committed by Andreas Kling
parent 6e5aa5d5df
commit 116c0c0ab3
2 changed files with 12 additions and 11 deletions

View file

@ -4,6 +4,12 @@ test("basic functionality", () => {
expect(Date.prototype).not.toHaveProperty("length");
});
test("string constructor", () => {
// The string constructor is the same as calling the timestamp constructor with the result of Date.parse(arguments).
// Since that has exhaustive tests in Date.parse.js, just do some light smoke testing here.
expect(new Date("2017-09-07T21:08:59.001Z").toISOString()).toBe("2017-09-07T21:08:59.001Z");
});
test("timestamp constructor", () => {
// The timestamp constructor takes a timestamp in milliseconds since the start of the epoch, in UTC.