Skip to content

Commit

Permalink
LibJS: Extend supported date string formats
Browse files Browse the repository at this point in the history
  • Loading branch information
kperdlich authored and trflynn89 committed Sep 20, 2024
1 parent 5ac0e81 commit a3472ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static double parse_date_string(VM& vm, ByteString const& date_string)
"%Y-%m-%eT%T%X%z"sv, // "2024-01-26T22:10:11.306+0000"
"%m/%e/%Y,%t%T%t%p"sv, // "1/27/2024, 9:28:30 AM"
"%Y-%m-%e"sv, // "2024-1-15"
"%Y-%m-%e%t%T%tGMT%z"sv // "2024-07-05 00:00:00 GMT-0800"
};

for (auto const& format : extra_formats) {
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibJS/Tests/builtins/Date/Date.parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test("basic functionality", () => {
expect(Date.parse("Sun Jan 21 2024 21:11:31 GMT 0100 (Central European Standard Time)")).toBe(
1705867891000
);
expect(Date.parse("2024-07-05 00:00:00 GMT-0200")).toBe(1720144800000);
expect(Date.parse("2024-01-15 00:00:01")).toBe(1705298401000);
expect(Date.parse("Tue Nov 07 2023 10:05:55 UTC")).toBe(1699351555000);
expect(Date.parse("Wed Apr 17 23:08:53 2019")).toBe(1555560533000);
Expand Down

0 comments on commit a3472ae

Please sign in to comment.