andyearnshaw / Intl.js

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

non-gregorian calendar #285

Closed sm2017 closed 6 years ago

sm2017 commented 6 years ago

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat

The following Unicode extension keys are allowed:

nu Numbering system. Possible values include: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt". ca Calendar. Possible values include: "buddhist", "chinese", "coptic", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamicc", "iso8601", "japanese", "persian", "roc".

I test the following code

var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
console.log(new Intl.DateTimeFormat(['fa-u-ca-persian-nu-arab']).format(date));

But the result is not persian calendar it is gregorian , How can I have non-gregorian calendar

caridy commented 6 years ago

This polyfill only support gregorian calendar ATM: https://github.com/andyearnshaw/Intl.js/blob/68514268e4f6b97a9323f6be9e75bd5a1216777a/README.md#not-implemented