GetFormatterParts failing on latest Firefox Nightly
See original GitHub issueFrom https://bugzilla.mozilla.org/show_bug.cgi?id=1742572:
Standalone test case:
function GetFormatterParts(timeZone, epochMilliseconds){ const formatter = new Intl.DateTimeFormat("en-us", { timeZone, hour12: false, era: "short", year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric" }); const datetime = formatter.format(new Date(epochMilliseconds)); const [date, fullYear, time] = datetime.split(/,\s+/); const [month, day] = date.split(" "); const [year, era] = fullYear.split(" "); const [hour, minute, second] = time.split(":"); return { year: era === "BC" ? -year + 1 : +year, month: +month, day: +day, hour: hour === "24" ? 0 : +hour, minute: +minute, second: +second }; } GetFormatterParts("America/Los_Angeles", Date.now());
GetFormatterParts
expects that the formatted date-time string can be split into three parts through the regular expression/,\s+/
. This worked before the update, because the formatted string looked like"11 23, 2021 AD, 05:00:00"
. But after the update to ICU 70, which includes an update to CLDR 40, the string now looks like"11/23/2021 A, 05:00:00"
, i.e. can no longer be separated into three parts when searching for a comma.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Firefox Nightly Error Collection - Mozilla Support
Firefox Nightly automatically collects and sends Mozilla information about JavaScript errors that occur within the browser itself (not on web pages).
Read more >Firefox Nightly 110.0a1, See All New Features ... - Mozilla
See what landed recently in Firefox Nightly! Release Notes tell you what's new in Firefox. As always, we welcome your feedback.
Read more >Firefox hangs or is not responding - How to fix
When Firefox hangs, it stops responding to your clicks and doesn't seem to do anything. This article covers the various solutions depending on...
Read more >Fix problems connecting to websites after updating Firefox
This article describes how to troubleshoot problems connecting to websites that start immediately after updating Firefox to a new version.
Read more >Firefox can't load websites but other browsers can
We'll explain errors such as "Server not found" or "Unable to connect" and how to fix problems where Firefox can't access websites but...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@justingrant mind releasing a new version with this fix?
I was thinking of a change for proposal-temporal such as this one:
We already use formatToParts in the calendar code so maybe it shouldn’t be a problem. On the other hand, it’s only used for non-ISO calendars, and this would require it more generally for ISO calendar usage as well. I’m not sure what formatToParts is transpiled to for old browsers that don’t support it. For the reference code in proposal-temporal I’m not concerned about old browsers (it’s been generally supported since 2018 or so) but for the polyfill it might matter.