LibJS: Parse dates like "Wednesday, Jan 15, 2025"

This was getting called on abc.com
This commit is contained in:
Shannon Booth 2025-01-15 21:47:00 +13:00 committed by Jelle Raaijmakers
parent e95096d2a9
commit 5aeae5e583
Notes: github-actions[bot] 2025-01-15 09:43:30 +00:00
2 changed files with 2 additions and 0 deletions

View file

@ -189,6 +189,7 @@ static double parse_date_string(VM& vm, StringView date_string)
"%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"
"%A,%t%h%t%d,%t%Y"sv, // "Wednesday, Jan 15, 2025"
"%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"

View file

@ -44,6 +44,7 @@ test("basic functionality", () => {
expect(Date.parse("November 19 2024 00:00:00 +0900")).toBe(1731942000000);
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);
// FIXME: Create a scoped time zone helper when bytecode supports the `using` declaration.
setTimeZone(originalTimeZone);