Intl.Locale.prototype.calendar
property is an accessor property which returns the type of calendar used in the
Locale
.
calendar
property returns the part of the
Locale
that indicates the
Locale
's calendar era. While most of the world uses the Gregorian calendar, there are several regional calendar eras used around the world. The following table shows all the valid Unicode calendar key strings, along with a description of the calendar era they represent.
| Calendar key (name) | 描述 |
|---|---|
buddhist
|
Thai Buddhist calendar |
chinese
|
Traditional Chinese calendar |
coptic
|
Coptic calendar |
dangi
|
Traditional Korean calendar |
ethioaa
|
Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) |
ethiopic
|
Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) |
gregory
|
Gregorian calendar |
hebrew
|
Traditional Hebrew calendar |
indian
|
Indian calendar |
islamic
|
Islamic calendar |
islamic-umalqura
|
Islamic calendar, Umm al-Qura |
islamic-tbla
|
Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) |
islamic-civil
|
Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) |
islamic-rgsa
|
Islamic calendar, Saudi Arabia sighting |
iso8601
|
ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) |
japanese
|
Japanese Imperial calendar |
persian
|
Persian calendar |
roc
|
Republic of China calendar |
islamicc
calendar key has been deprecated. Please use
islamic-civil
.
|
Civil (algorithmic) Arabic calendar |
Calendar eras fall under the category of locale key "extension keys". These keys add additional data about the locale, and are added to locale identifiers by using the
-u
extension. Thus, the calendar era type can be added to the inital locale identifier string that is passed into the
Intl.Locale
constructor. To add the calendar type, first add the
-u
extension to the string. Next, add the
-ca
extension to indicate that you are adding a calendar type. Finally, add the calendar era to the string.
let frBuddhist = new Intl.Locale("fr-FR-u-ca-buddhist");
console.log(frBuddhist.calendar); // Prints "buddhist"
Intl.Locale
constructor has an optional configuration object argument, which can contain any of several extension types, including calendars. Set the
calendar
property of the configuration object to your desired calendar era, and then pass it into the constructor.
let frBuddhist = new Intl.Locale("fr-FR", {calendar: "buddhist"});
console.log(frBuddhist.calendar); // Prints "buddhist"
| 规范 |
|---|
| ECMAScript 国际化 API (ECMA-402) |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
calendar
|
Chrome 74 | Edge 79 | Firefox 75 | IE No | Opera 62 | Safari 14 | WebView Android 74 | Chrome Android 74 | Firefox Android No | Opera Android 53 | Safari iOS 14 | Samsung Internet Android 11.0 |
nodejs
12.0.0
|
完整支持
不支持
见实现注意事项。
Intl
Collator
DateTimeFormat
ListFormat
NumberFormat
PluralRules
RelativeTimeFormat
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()