-
Notifications
You must be signed in to change notification settings - Fork 215
Formatting month - value of long falling back to short #179
Comments
@Arturszott In any case, I will take a look at this. At first glance, it seems that https://github.com/andyearnshaw/Intl.js/blob/master/src/12.datetimeformat.js#L609-L734 algo is not choosing the right pattern, which is clearly available as yMMMM here https://github.com/andyearnshaw/Intl.js/blob/master/locale-data/json/en.json#L65, we will have to make the right adjustments there to guarantee that. |
This also seems to be happening for weekday as well, it's always falling back to short in my tests. And year seems to always be forced to the full 4 digits (though i guess this may have been intentional, 2 digit years are kind of strange and can only makes sense in a m/d/y case anyway, i just know that you could do it before the recent release) |
@caridy Is the console.log(
new IntlPolyfill.DateTimeFormat(
"en", {
year: "numeric",
month: "long"
}
).format(new Date('January 15'))
)
// => January 2015 At first, we can make algo of |
Using Intl.js > const intl = require("intl")
undefined
> intl
{ getCanonicalLocales: [Function],
__localeSensitiveProtos:
{ Number: { toLocaleString: [Function] },
Date:
{ toLocaleString: [Function],
toLocaleDateString: [Function],
toLocaleTimeString: [Function] } } }
> new intl.DateTimeFormat('sv', {"weekday": "short"}).format(new Date("08/14/2016"))
'sön'
> new intl.DateTimeFormat('sv', {"weekday": "long"}).format(new Date("08/14/2016"))
'sön' <-- should be söndag
> new intl.DateTimeFormat('dk', {"weekday": "short"}).format(new Date("08/14/2016"))
'So.'
> new intl.DateTimeFormat('dk', {"weekday": "long"}).format(new Date("08/14/2016"))
'So.' <-- should be Søndag Some further examples > new intl.DateTimeFormat('es', {"month": "long"}).format(new Date("08/14/2016"))
'ago.' <-- should be agosto
> new intl.DateTimeFormat('no', {"month": "long"}).format(new Date("08/14/2016"))
'Aug.' <-- should be August
> new intl.DateTimeFormat('sv', {"month": "long"}).format(new Date("10/12/2016"))
'okt.' <-- should be oktober
> new intl.DateTimeFormat('sv', {"weekday": "narrow"}).format(new Date("10/12/2016"))
'ons' <-- should be O
> new intl.DateTimeFormat('en', {"weekday": "narrow"}).format(new Date("10/12/2016"))
'Wed' <-- should be W |
yeah, single entry matches are not a thing in CLDR, it seems that browsers are doing their own thing when it comes to format one element, we will have to add that into data or a custom resolution for that in |
This looks like a regression. It was working in version 1.1.0. |
yeah, but it broke many other things from 1.0.0. I have discussed this extensibly with @ericf, and now we just need help to tune-in the |
Because now server incorrectly renders short date when long is defined - andyearnshaw/Intl.js#179 Will be fixed soon, but people can be confused with “React attempted to reuse markup in a container but the checksum was invalid.”
using |
@watilde the |
Yay. Does the merge above that closes this also cover the long weekday issues @mkohlmyr brought up? |
Example failing test case:
expected value January 2016 but the actual value is Jan 2016
I've been digging it for a while and it looks like bestFormat is not the best :)
Cheers!
The text was updated successfully, but these errors were encountered: