Spin off from #190
The issue is what part of the specification decide which glue pattern should be used.
@caridy commented on Oct 27, 2017
In most cases, you can get away with transforming a pattern/skeleton into a DateTimeFormat options, specially if you're flexible with the output. E.g.:
var f = {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: '2-digit',
second: '2-digit',
hour12: true,
timeZoneName: 'long'
};
new Intl.DateTimeFormat('en-US', f).format(Date.now())
"Friday, October 27, 2017, 4:14:53 PM Eastern Daylight Time"
Most browsers, today, will add a comma after the year (IE11 does something slightly different) for that set of options. But if you look at the latest ICU library, we see this pattern: "EEEE, MMMM d, y 'at' h:mm:ss a zzzz", which does have an at in between and no coma for en-US.
I wrote some experimental library to try to see if we can help people who want to use patterns/skeleton for convenience, but still preserving the invariants of Intl to do the right thing depending of the locale.
https://github.com/caridy/intl-datetimeformat-pattern
With a library like this, you can get from that pattern/skeleton to the most likely option object that will produce something very similar, but in some cases slightly different due to the those weird differences.
I wonder if someone can actually explain the difference between ICU and browsers for something like the example above?
@jungshik ommented on Nov 22, 2017
@rxaviers is right on 'at' for en-US and CLDR 'glue pattern'. The fact that v8 does not do that is a bug. I thought I had filed a bug on that against v8, but I couldn't find it. Filed https://bugs.chromium.org/p/v8/issues/detail?id=7116 .BTW, this issue is not about 'skeleton' (#189) but about 'pattern'. The former (skeleton) will take a list of fields and field lengths and produce locale-dependent output (order can be shuffled, for instance).
@FrankYFTang wrote:
https://github.com/unicode-cldr/cldr-dates-full/blob/32.0.0/main/en/ca-gregorian.json#L335
show me
"dateTimeFormats": {
"full": "{1} 'at' {0}",
"long": "{1} 'at' {0}",
"medium": "{1}, {0}",
"short": "{1}, {0}",
It is not clear to me which part of the specification determine WHICH glue pattern it should use? Why should it use the "full" one but not the "short" one?
Spin off from #190
The issue is what part of the specification decide which glue pattern should be used.
@caridy commented on Oct 27, 2017
@jungshik ommented on Nov 22, 2017
@FrankYFTang wrote: