globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 605 forks source link

Matching to close patterns in Globalize #773

Open cahuja opened 7 years ago

cahuja commented 7 years ago

Matching to close patterns has different behavior in ICU4j and Globalize and here is an example of the difference. Consider the pattern "yyMD" in locale "en-SG"

As per CLDR data, the following pattern exists -

"yMd" -> "dd/MM/y"

Now, when this same pattern (yMd) is run through Globalize and ICU4j, we get the expected result which is "dd/MM/y"

However, when I pass the pattern (yyMd) though Globalize and ICU4j, the results differ - Globalize (yyMd) -> dd/MM/yy ICU4j (yyMd) -> d/M/yy

When I read TR-35, I see that the notion of distance between y and yy would apply in a similar manner to how it would apply for MMM and MMMM as given in the example. In this case, I believe Globalize should be correct, but I would like another opinion before being sure to mark this as a spec bug.

Thoughts @rxaviers?

rxaviers commented 7 years ago

Yeap, I read it the same way. Let's file UTS bug.

rxaviers commented 7 years ago

Or is it an ICU bug?

rxaviers commented 7 years ago

Perhaps @srl295 could shed some light...

srl295 commented 7 years ago

@rxaviers it's a great question, can you send a note to cldr-users? I can confirm as with the links below: icu4j yMd@en-SG dd/MM/y icu4j yyMd@en-SG d/M/yy

rxaviers commented 7 years ago

Ok thanks @srl295