-
Notifications
You must be signed in to change notification settings - Fork 215
1.1.0 has issues with Intl.DateTimeFormat #152
Comments
Yeah, I figure this was going to be a problem. 1.1.0 fixes a bunch of issues when the options are overruling the best fit options, but that introduces this problem. The resolution is to follow CLDR rules for the closest distance, in which case, the fact that for certain locales, the options from the example above will produce pattern: Note: this most likely solve many of the remaining issues with datatime format. |
I know this is tricky and ambiguous as to what browsers do when handling the formatting options — it's clear they are simply calling into ICU. The reason I'm setting The problem is these edge cases are locale specific, so for browsers' current impls they choose what's colloquial for the locale over the explicit options. Unless ECMA 402 tightens this aspect of the spec, I think the polyfill should behave the same — hopefully this doesn't mean we have to code in a bunch of exceptions per locale :-/ |
@ericf that's correct! the error here is that Intl.js was implementing an strict |
btw, this is related to this tc39/ecma402#58 |
@caridy and I discussed this at length and figure out the issue which is was how the options → skeleton → format pattern The user-specified English Example: let df = new Intl.DateTimeFormat('en', {month: 'long'});
console.log(df.format(Date.now())); // "April"
Japanese Example: let df = new Intl.DateTimeFormat('ja', {month: 'long'});
console.log(df.format(Date.now())); // "4月"
Note: How the user-specified option of This means that when we process/expand the format patterns we have to do so in a non-lossy way so that we retain the information about how to format each part of the pattern. |
Is there a workaround for this? I'm running an issue where we use react-intl but I need Intl.js polyfill for PhantomJS for our tests. If I use Intl.js version 1.1.0, the leading zero in the minutes is dropped off. If I use 1.0.1, the leading 0 for "00:00" is dropped (it's rendered as "0:00"). |
I'm planning to release 1.2 tomorrow :) |
fixed by #171 |
Similar can be demonstrated here;
– https://tonicdev.com/5735aba53ed13c11004b5696/5735aba53ed13c11004b5697 should be EDIT Last version that worked was 1.0.1;
– https://tonicdev.com/5735aba53ed13c11004b5696/5735ad8dfba2ae1200967830 EDIT 2 ...but that shows |
1.2.3 version still does not solve it (( |
I noticed that 1.1.0 isn't properly formatting times, when the minutes are less than 10 the leading
0
is missing; e.g.,The text was updated successfully, but these errors were encountered: