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

瀏覽器相容性

另見