mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibJS: Parse dates like "Jan 15, 2025"
This commit is contained in:
parent
4bb22c52d1
commit
f92d037752
Notes:
github-actions[bot]
2025-02-14 11:28:33 +00:00
Author: https://github.com/Psychpsyo Commit: https://github.com/LadybirdBrowser/ladybird/commit/f92d0377524 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3570
2 changed files with 2 additions and 0 deletions
|
@ -196,6 +196,7 @@ static double parse_date_string(VM& vm, StringView date_string)
|
|||
"%Y-%m-%d%t%H:%M:%S%X"sv, // "2025-01-13 00:00:00.000"
|
||||
"%Y-%m-%eT%T%z"sv, // "2021-04-21T15:00:00+0000"
|
||||
"%d%t%b%t%Y%t%T%t%Z"sv, // "1 Jan 2001 00:00:00 GMT"
|
||||
"%b%t%d,%t%Y"sv, // "Jan 15, 2025"
|
||||
};
|
||||
|
||||
for (auto const& format : extra_formats) {
|
||||
|
|
|
@ -48,6 +48,7 @@ test("basic functionality", () => {
|
|||
expect(Date.parse("2025-01-13 00:00:00.000")).toBe(1736748000000);
|
||||
expect(Date.parse("2021-04-21T15:00:00+0000")).toBe(1619017200000);
|
||||
expect(Date.parse("1 Jan 2001 00:00:00 GMT")).toBe(978307200000);
|
||||
expect(Date.parse("Jul 05, 2024")).toBe(1720155600000);
|
||||
|
||||
// FIXME: Create a scoped time zone helper when bytecode supports the `using` declaration.
|
||||
setTimeZone(originalTimeZone);
|
||||
|
|
Loading…
Add table
Reference in a new issue