Temporal.PlainYearMonth.prototype.era

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Thuộc tính truy cập era của các thực thể Temporal.PlainYearMonth trả về một chuỗi viết thường đặc thù của lịch đại diện cho kỷ nguyên của year-month này, hoặc undefined nếu lịch không sử dụng kỷ nguyên (ví dụ: ISO 8601). eraeraYear cùng nhau xác định duy nhất một năm trong một lịch, giống như cách year làm. Nó phụ thuộc vào lịch.

Set accessor của eraundefined. Bạn không thể thay đổi thuộc tính này trực tiếp. Dùng phương thức with() để tạo một đối tượng Temporal.PlainYearMonth mới với giá trị mong muốn.

Để biết thông tin chung và thêm ví dụ, xem Temporal.PlainDate.prototype.era.

Ví dụ

Sử dụng era

js
const ym = Temporal.PlainYearMonth.from("2021-07"); // ISO 8601 calendar
console.log(ym.era); // undefined

const ym2 = Temporal.PlainYearMonth.from("2021-07-01[u-ca=gregory]");
console.log(ym2.era); // ce

Đặc tả

Thông số kỹ thuật
Temporal
# sec-get-temporal.plainyearmonth.prototype.era

Tương thích trình duyệt

Xem thêm