andyearnshaw / Intl.js

Compatibility implementation of the ECMAScript Internationalization API (ECMA-402) for JavaScript -- UNMAINTAINED
Other
1.7k stars 215 forks source link

DateTimeFormat weekday long always shows short version #302

Open grean opened 6 years ago

grean commented 6 years ago

Hi Andy, In a react native project, i import latest intl (1.2.5) package :

Intl = require('intl');
require('intl/locale-data/jsonp/en.js');

and use it like this : new Intl.DateTimeFormat('en', { weekday: 'long', day: '2-digit', month: '2-digit' }).format(new Date("2018-01-25T00:00:00"))

but it shows : Thu, 1/25 instead of Thuesday, 1/25

this code works great in normals browsers without polyfill in a react app.

In this file : intl/locale-data/jsonp/en.js, i've changed the value of (2nd gregory, there are two in this file , don't know why) gregory.days.short from 'Thu' to 'Thursday' and it changes the display to Thuesday, 1/25. I think the 'long' value of weekday option is not taken into account but only the short one.

Any idea ?

christophehurpeau commented 6 years ago

It seems it should be in formats to work. You can try to add in jsonp/en.js in date.formats.dateFormats:

EEEEMMdd: 'EEEE, MM/dd',

(for me it was MMMMEEEEd:"EEEE, MMMM d" for weekday: 'long', month: 'long', day: 'numeric')