diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index 9138e1d6ebb..f965f7375fa 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -168,6 +168,7 @@ static double parse_date_string(ByteString const& date_string) "%m/%e/%Y%t%R%t%z"sv, // "12/05/2022 10:00 -0800" "%Y/%m/%e%t%R"sv, // "2014/11/14 13:05" "%Y-%m-%e%t%R"sv, // "2014-11-14 13:05" + "%B%t%e,%t%Y"sv, // "June 5, 2023" "%B%t%e,%t%Y%t%T"sv, // "June 5, 2023 17:00:00" "%b%t%d%t%Y%t%Z"sv, // "Jan 01 1970 GMT" "%a%t%b%t%e%t%T%t%Y%t%z"sv, // "Wed Apr 17 23:08:53 2019 +0000" diff --git a/Userland/Libraries/LibJS/Tests/builtins/Date/Date.parse.js b/Userland/Libraries/LibJS/Tests/builtins/Date/Date.parse.js index 7db796d8c32..7ed70ea11af 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Date/Date.parse.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Date/Date.parse.js @@ -121,6 +121,20 @@ test("yy{/,-}mm{/,-}dd hh:mm extension", () => { expectStringToGiveDate("2014-11-14 13:05", 2014, 11, 14, 13, 5); }); +test("Month dd, yy extension", () => { + function expectStringToGiveDate(input, fullYear, month, dayInMonth) { + const date = new Date(Date.parse(input)); + expect(date.getFullYear()).toBe(fullYear); + expect(date.getMonth() + 1).toBe(month); + expect(date.getDate()).toBe(dayInMonth); + } + + expectStringToGiveDate("May 15, 2023", 2023, 5, 15); + expectStringToGiveDate("May 22, 2023", 2023, 5, 22); + expectStringToGiveDate("May 30, 2023", 2023, 5, 30); + expectStringToGiveDate("June 5, 2023", 2023, 6, 5); +}); + test("Month dd, yy hh:mm:ss extension", () => { function expectStringToGiveDate(input, fullYear, month, dayInMonth, hours, minutes, seconds) { // Since the timezone is not specified we just say it has to equal the date parts.