Temporal.PlainDate.prototype.calendarId

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

实验性: 这是一项实验性技术
在生产中使用此技术之前,请仔细检查浏览器兼容性表格

calendarId 访问器属性是 Temporal.PlainDate 实例,用于返回一个字符串,表示用于解释内部 ISO 8601 日期的 日历

有关常用日历类型的列表,请参阅Intl.supportedValuesOf()

calendarId 的 set 访问器为 undefined。您不能直接更改此属性。请使用 withCalendar() 方法创建一个具有所需新值的 Temporal.PlainDate 新对象。

示例

使用 calendarId

js
const date = Temporal.PlainDate.from("2021-07-01");
console.log(date.calendarId); // "iso8601"; default

const date2 = Temporal.PlainDate.from("2021-07-01[u-ca=chinese]");
console.log(date2.calendarId); // "chinese"

const date3 = date2.withCalendar("hebrew");
console.log(date3.calendarId); // "hebrew"

规范

规范
Temporal
# sec-get-temporal.plaindate.prototype.calendarid

浏览器兼容性

另见