diff options
author | Linus Groh <mail@linusgroh.de> | 2021-07-31 13:54:08 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-07-31 13:54:25 +0100 |
commit | 95331ea86475d2d2131ef42e8bf9f07803425676 (patch) | |
tree | 6e6742d7b8b87d0ce73d7ef4cdfcc841e3a66951 /Userland/Libraries | |
parent | cab1015a03c3f7db042507e3d5ee7edde8c079b5 (diff) | |
download | serenity-95331ea86475d2d2131ef42e8bf9f07803425676.zip |
LibJS/Tests: Fix Temporal.Now.plainDateTime{,ISO}() epoch calculation
Combining month and day like this doesn't always yield correct results.
Use dayOfYear multiplied by the seconds per day instead, which does.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTime.js | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTimeISO.js | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTime.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTime.js index 0ff22d80ff..7639283295 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTime.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTime.js @@ -20,8 +20,7 @@ describe("correct behavior", () => { const plainDateTimeToEpochSeconds = plainDateTime => (plainDateTime.year - 1970) * 31_556_952 + - plainDateTime.month * 2_630_000 + - plainDateTime.day * 86_400 + + plainDateTime.dayOfYear * 86_400 + plainDateTime.hour * 3_600 + plainDateTime.minute * 60 + plainDateTime.second + diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTimeISO.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTimeISO.js index 9fd61584bb..63eab85628 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTimeISO.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Now/Now.plainDateTimeISO.js @@ -18,8 +18,7 @@ describe("correct behavior", () => { const plainDateTimeToEpochSeconds = plainDateTime => (plainDateTime.year - 1970) * 31_556_952 + - plainDateTime.month * 2_630_000 + - plainDateTime.day * 86_400 + + plainDateTime.dayOfYear * 86_400 + plainDateTime.hour * 3_600 + plainDateTime.minute * 60 + plainDateTime.second + |