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
commit 116c0c0ab3
Notes: sideshowbarker 2024-07-19 03:20:46 +09:00
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.