LibJS: Parse dates like "Wed Nov 20 2024"

This commit is contained in:
rmg-x 2024-11-19 21:53:14 -06:00 committed by Tim Ledbetter
parent dabf3da7e5
commit 74b27d620d
Notes: github-actions[bot] 2024-11-20 09:21:48 +00:00
2 changed files with 2 additions and 0 deletions

View file

@ -192,6 +192,7 @@ static double parse_date_string(VM& vm, ByteString const& date_string)
"%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"
"%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"
};
for (auto const& format : extra_formats) {

View file

@ -41,6 +41,7 @@ test("basic functionality", () => {
expect(Date.parse("01 February 2013")).toBe(1359698400000);
expect(Date.parse("Tuesday, October 29, 2024, 18:00 UTC")).toBe(1730224800000);
expect(Date.parse("November 19 2024 00:00:00 +0900")).toBe(1731942000000);
expect(Date.parse("Wed Nov 20 2024")).toBe(1732082400000);
// FIXME: Create a scoped time zone helper when bytecode supports the `using` declaration.
setTimeZone(originalTimeZone);