LibJS: Parse dates like "Tuesday, October 29, 2024, 18:00 UTC"

This format is used on https://jetbrains.com/
This commit is contained in:
Andreas Kling 2024-10-30 10:24:10 +01:00 committed by Andreas Kling
parent 14e1e55319
commit 3180df3337
Notes: github-actions[bot] 2024-10-30 10:27:16 +00:00
2 changed files with 2 additions and 0 deletions

View file

@ -190,6 +190,7 @@ static double parse_date_string(VM& vm, ByteString const& date_string)
"%d%t%B%t%Y%t%R"sv, // "01 February 2013 08:00"
"%d%t%b%t%Y"sv, // "01 Jan 2000"
"%d%t%b%t%Y%t%R"sv, // "01 Jan 2000 08:00"
"%A,%t%B%t%e,%t%Y,%t%R%t%Z"sv, // "Tuesday, October 29, 2024, 18:00 UTC"
};
for (auto const& format : extra_formats) {

View file

@ -39,6 +39,7 @@ test("basic functionality", () => {
expect(Date.parse("2024-01-26T22:10:11.306+0000")).toBe(1706307011000); // FIXME: support sub-second precision
expect(Date.parse("1/27/2024, 9:28:30 AM")).toBe(1706369310000);
expect(Date.parse("01 February 2013")).toBe(1359698400000);
expect(Date.parse("Tuesday, October 29, 2024, 18:00 UTC")).toBe(1730224800000);
// FIXME: Create a scoped time zone helper when bytecode supports the `using` declaration.
setTimeZone(originalTimeZone);