Intl.Locale.prototype.calendar - JavaScript 编辑

The Intl.Locale.prototype.calendar property is an accessor property which returns the type of calendar used in the Locale.

Description

The 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.

Unicode calendar keys

Unicode calendar keys
Calendar key (name)Description
buddhistThai Buddhist calendar
chineseTraditional Chinese calendar
copticCoptic calendar
dangiTraditional Korean calendar
ethioaaEthiopic calendar, Amete Alem (epoch approx. 5493 B.C.E)
ethiopicEthiopic calendar, Amete Mihret (epoch approx, 8 C.E.)
gregoryGregorian calendar
hebrewTraditional Hebrew calendar
indianIndian calendar
islamicIslamic calendar
islamic-umalquraIslamic calendar, Umm al-Qura
islamic-tblaIslamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch)
islamic-civilIslamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch)
islamic-rgsaIslamic calendar, Saudi Arabia sighting
iso8601ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules)
japaneseJapanese Imperial calendar
persianPersian calendar
rocRepublic of China calendar
The islamicc calendar key has been deprecated. Please use islamic-civil.

islamicc

Civil (algorithmic) Arabic calendar

Examples

Adding a calendar in the Locale string

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"

Adding a calendar with a configuration object

The 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"

Specifications

Specification
ECMAScript Internationalization API (ECMA-402)

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:93 次

字数:6181

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文