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 |
瀏覽器相容性
載入中…