LibJS: Allow date format "YYYY-M-DD"
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Arhcout 2024-09-14 12:21:10 +02:00 committed by Tim Flynn
parent 6481ef821d
commit b4d996680a
Notes: github-actions[bot] 2024-09-15 16:25:28 +00:00
2 changed files with 3 additions and 1 deletions

View file

@ -180,6 +180,7 @@ static double parse_date_string(VM& vm, ByteString const& date_string)
"%a%t%b%t%e%t%T%t%Y"sv, // "Wed Apr 17 23:08:53 2019"
"%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"
};
for (auto const& format : extra_formats) {

View file

@ -16,6 +16,8 @@ test("basic functionality", () => {
const originalTimeZone = setTimeZone("UTC");
expect(Date.parse("1980-5-30")).toBe(328492800000);
setTimeZone("America/Chicago");
expect(Date.parse("Jan 01 1970 GMT")).toBe(0);
expect(Date.parse("Wed Apr 17 23:08:53 2019 +0000")).toBe(1555542533000);
@ -42,7 +44,6 @@ test("basic functionality", () => {
expect(Date.parse("1980-05-00T")).toBe(NaN);
expect(Date.parse("1980-05-00T15:15:")).toBe(NaN);
expect(Date.parse("1980-05-00T15:15:15.")).toBe(NaN);
expect(Date.parse("1980-5-30")).toBe(NaN);
expect(Date.parse("1980-05-30T13")).toBe(NaN);
expect(Date.parse("1980-05-30T13:4")).toBe(NaN);
expect(Date.parse("1980-05-30T13:40+")).toBe(NaN);