mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibJS: Parse dates like "Wed Nov 20 2024"
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user