luxon
luxon copied to clipboard
Calculating wrong timezone offsets for BC timestamps in FF
Describe the bug
In Firefox 104.0.2, Intl.DateTimeFormat().formatToParts()
returns values for "era"
as either A
(for "AD"), or B
(for "BC") - this makes this check a false negative, leading Luxon to calculate the wrong timezone offset in Firefox.
To Reproduce Any code that queries BC dates' offsets triggers this, but as an example, here is a fiddle that returns different offsets in v8 (edge) and SpiderMonkey (FF): http://jsfiddle.net/90sp614f/
Here is the userspace code I used if you just want to skim it through:
luxon.DateTime.fromObject({year:-1234, month:9, day:25}).setZone('Europe/Budapest').offset
Results:
v8: 76.33333333333333
SpiderMonkey: 1298569036.3333333
Actual vs Expected behavior
They both should print 76.33333333333333
(as I guess v8 is correct).
Desktop (please complete the following information):
- OS: Windows
- Browser Edge 105.0.1343.33, Firefox 104.0.2
- Luxon version 3.0.3
- Your timezone "Europe/Budapest"
Additional context -
Ok, sure, I'd take a fix making that line check for B
This was fixed in Firefox 106. ~~But because the workaround is so simple, I will submit a quick PR.~~ Never mind, this only happens for dates in BC and it's only in about 20 versions of Firefox that now have less than 0.2% market share combined. I don't think that is worth maintaining a workaround for.