From 3ab4efb7efe771d74daa48059414c8e57561fb73 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 17 Jan 2025 16:50:45 +0000 Subject: [PATCH] LibJS: Parse dates like "2025-01-13 00:00:00.000" This is used on figma.com. --- Libraries/LibJS/Runtime/DateConstructor.cpp | 1 + Libraries/LibJS/Tests/builtins/Date/Date.parse.js | 1 + 2 files changed, 2 insertions(+) diff --git a/Libraries/LibJS/Runtime/DateConstructor.cpp b/Libraries/LibJS/Runtime/DateConstructor.cpp index d4723690de1..505d53fb3df 100644 --- a/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -193,6 +193,7 @@ static double parse_date_string(VM& vm, StringView date_string) "%B%t%d%t%Y%t%T%t%z"sv, // "November 19 2024 00:00:00 +0900" "%a%t%b%t%e%t%Y"sv, // "Wed Nov 20 2024" "%Y-%m-%d%t%H:%M:%S%z"sv, // "2024-12-30 03:00:00+0000" + "%Y-%m-%d%t%H:%M:%S%X"sv, // "2025-01-13 00:00:00.000" }; for (auto const& format : extra_formats) { diff --git a/Libraries/LibJS/Tests/builtins/Date/Date.parse.js b/Libraries/LibJS/Tests/builtins/Date/Date.parse.js index 7526eca6b97..1759b76d7b3 100644 --- a/Libraries/LibJS/Tests/builtins/Date/Date.parse.js +++ b/Libraries/LibJS/Tests/builtins/Date/Date.parse.js @@ -45,6 +45,7 @@ test("basic functionality", () => { expect(Date.parse("Wed Nov 20 2024")).toBe(1732082400000); expect(Date.parse("2025-01-02 14:00:00+0000")).toBe(1735826400000); expect(Date.parse("Wednesday, Jan 15, 2025")).toBe(1736920800000); + expect(Date.parse("2025-01-13 00:00:00.000")).toBe(1736748000000); // FIXME: Create a scoped time zone helper when bytecode supports the `using` declaration. setTimeZone(originalTimeZone);