globalize icon indicating copy to clipboard operation
globalize copied to clipboard

Unexpected matching in Polish format in Globalize

Open cahuja opened this issue 8 years ago • 1 comments

Polish (pl) for the format (yLLL) has the following issue -

Given that M and L has a small distance from each other, I would expect the format to be "LLL y". However, for Polish I am seeing unexpected results These are the results I am seeing with Globalize

yMMM (01 Jan 2017) -> 01.2017 yLLL (01 Jan 2017) -> sty.2017

While ICU4j has the results as -

yLLL (01 Jan 2017) -> sty 2017

For yMMM, we are getting the closest result as yM -> "MM.y". This is already pretty strange considering the data has "yMMM" -> "LLL y". Now, yLLL is matching to yM and then replacing MM with LLL (which is totally strange).

See the code sample below -

//Setup
const Globalize = require('globalize');
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor('pl') );
Globalize.locale('pl');

const formatterOptions = {
  skeleton: 'yLLL',
};

// Create a localized formatter.
const f = Globalize.dateFormatter(formatterOptions);

// Format a localized date
const localDate = f(new Date(2017,00,01));

// Setup en-US data
Globalize.load( require( "cldr-data" ).entireMainFor('en') );
Globalize.locale('en-US');

// Create an english formatter
const f2 = Globalize.dateFormatter(formatterOptions);
const englishDate = f2(new Date(2017,00,01));

console.log(localDate);
// sty.2017

console.log(englishDate);
// Jan 2017 

cahuja avatar Aug 31 '17 18:08 cahuja

A workaround that worked was to explicitly provide yLLL as a format so that I avoid the matching code altogether and concat this with the CLDR data.

cahuja avatar Aug 31 '17 18:08 cahuja