Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

I ran a simple test and is not returning the right data #39

Closed
lwelti opened this issue Dec 18, 2013 · 5 comments
Closed

I ran a simple test and is not returning the right data #39

lwelti opened this issue Dec 18, 2013 · 5 comments

Comments

@lwelti
Copy link

lwelti commented Dec 18, 2013

I did a simple test:
script src="../Intl.complete.js"

then I have:
var lang = "es-MX";
var date = new Date(Date.UTC(2010,1,9,3,0,0));

then I have:
var options = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
document.write(new IntlPolyfill.DateTimeFormat(lang, options).format(date));

and no matter which format I am using it always returns:

"lun, 8 '{day}{weekday}' febrero '{day}{weekday}' 2010"

vs if I use Intl.DateTimeFormat returns:
"lunes 8 de febrero de 2010"

IntlPolyfill is not returning OK data

@caridy
Copy link
Collaborator

caridy commented Dec 18, 2013

hmm, something is messed up in the issue report @lwelti, make sure you use triple ` to enclose code.

@lwelti
Copy link
Author

lwelti commented Dec 18, 2013

check again, i removed the script tags, but if this is really an issue we are in trouble.

@andyearnshaw
Copy link
Owner

It looks like this affects all es- locale data, because there's literal strings that I missed in the date format mappings, e.g. "full": "EEEE, d 'de' MMMM 'de' y".

I didn't account for this, and the intl402 tests don't test for it either, so it got missed. I'll try and get it fixed this morning if I have a bit of free time.

@lwelti
Copy link
Author

lwelti commented Dec 18, 2013

that only solves one issue, but is still wrong in some formats.

Using Intl Object:
var options = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
document.write(new Intl.DateTimeFormat(lang, options).format(date));

returns:
lunes 8 de febrero de 2010

Using IntlPolyfill:
var options = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
document.write(new IntlPolyfill.DateTimeFormat(lang, options).format(date));

returns:
lun, 8 de febrero de 2010


All the week formats, return the same value:

lun, 8 de febrero de 2010


var options = {month: "long"};
document.write(new IntlPolyfill.DateTimeFormat(lang, options).format(date));

returns:
feb 2010

instead of:
febrero

@andyearnshaw
Copy link
Owner

@lwelti: see my reply to your new issue, #40.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants