Closed Bug 1783731 Opened 2 years ago Closed 6 months ago

be more strict with Date.parse('YYYY-MM-D'), don't treat it as ISO 8601 and don't generate a UTC Date

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
121 Branch
Tracking Status
firefox121 --- fixed

People

(Reporter: aryx, Assigned: vinny.diehl)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-needed, parity-chrome)

Attachments

(1 file)

Date.parse('2022-08-08') - Date.parse('2022-08-8') returns 0 in Firefox but the timezone offset it milliseconds in Chrome.

Firefox should only regard YYYY-MM-DD as valid ISO 8601 input which gets assumed as UTC.

Blocks: 1274354

Ok, to refine the bug content, the problem is that:

In Firefox:

> Date.parse("2022-08-8") - Date.parse("2022-08-08 00:00:00+0000")
0
> Date.parse("2022-08-08") - Date.parse("2022-08-08 00:00:00+0000")
0
> Date.parse("2022-08-08 00:00:00") - Date.parse("2022-08-08 00:00:00+0000")
-7200000

Whereas Chromium has the following output:

> Date.parse("2022-08-8") - Date.parse("2022-08-08 00:00:00+0000")
-7200000
> Date.parse("2022-08-08") - Date.parse("2022-08-08 00:00:00+0000")
0
> Date.parse("2022-08-08 00:00:00") - Date.parse("2022-08-08 00:00:00+0000")
-7200000

From my point of view, 2022-08-8, 2022-08-08 and 2022-08-08 00:00:00 should all have the same output, as no offset is defined, they should all have the same inferred timezone offset.

Date.parse("2022-08-08 00:00:00") - Date.parse("2022-08-08 00:00:00+0000")

FYI: In FF the last one reveals your current timezone offset. For example with RFP enabled, it returns 0. So -720000 is 10 hrs or -1200, which makes August 8th 2022, one of these (assuming my math is correct, and you have enabled DST on your system):

  • America/Anchorage, America/Juneau, America/Metlakatla, America/Nome, America/Sitka, America/Yakutat, Etc/GMT+8, Pacific/Pitcairn

[1] https://arkenfox.github.io/TZP/tests/timezones.html > type 2022 into field and hit [combine years]

  • I cheated and modified the code just for August 8th 2022
Severity: -- → S3
Priority: -- → P3
Keywords: parity-chrome
Assignee: nobody → vinny.diehl
Status: NEW → ASSIGNED
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/fb640e018d72
Don't parse single digit mon or mday as an ISO date r=arai
See Also: → 1863126
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch
Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: