Temporal.ZonedDateTime.prototype.calendarId
Temporal.ZonedDateTime
实例的 calendarId
访问器属性返回一个字符串,表示用于解释内部 ISO 8601 日期的日历。
有关常用日历类型的列表,请参阅Intl.supportedValuesOf()
。
calendarId
的设置器为 undefined
。您不能直接更改此属性。请使用withCalendar()
方法创建一个新的 Temporal.ZonedDateTime
对象,并带有所需的新值。
示例
使用 calendarId
js
const dt = Temporal.ZonedDateTime.from(
"2021-07-01T08:00:00-04:00[America/New_York]",
);
console.log(dt.calendarId); // "iso8601"; default
const dt2 = Temporal.ZonedDateTime.from(
"2021-07-01T08:00:00+08:00[Asia/Shanghai][u-ca=chinese]",
);
console.log(dt2.calendarId); // "chinese"
const dt3 = dt2.withCalendar("hebrew");
console.log(dt3.calendarId); // "hebrew"
规范
规范 |
---|
Temporal # sec-get-temporal.zoneddatetime.prototype.calendarid |
浏览器兼容性
加载中…