Temporal.PlainYearMonth.prototype.monthCode
Limited availability
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 monthCode của các thực thể Temporal.PlainYearMonth trả về một chuỗi đặc thù của lịch đại diện cho tháng của year-month này. Nó phụ thuộc vào lịch.
Thường là M cộng với số tháng hai chữ số. Đối với tháng nhuận, đây là mã của tháng trước theo sau là L (ngay cả khi về mặt khái niệm nó là dẫn xuất của tháng tiếp theo; ví dụ, trong lịch Hebrew, Adar I có mã M05L nhưng Adar II có mã M06). Nếu tháng nhuận là tháng đầu tiên của năm, mã là M00L.
Set accessor của monthCode là undefined. 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.monthCode.
Ví dụ
>Sử dụng monthCode
const date = Temporal.PlainYearMonth.from("2021-07-01"); // ISO 8601 calendar
console.log(date.monthCode); // "M07"
console.log(date.month); // 7
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.plainyearmonth.prototype.monthcode> |
Tương thích trình duyệt
Xem thêm
Temporal.PlainYearMonthTemporal.PlainYearMonth.prototype.with()Temporal.PlainYearMonth.prototype.add()Temporal.PlainYearMonth.prototype.subtract()Temporal.PlainYearMonth.prototype.yearTemporal.PlainYearMonth.prototype.monthTemporal.PlainYearMonth.prototype.daysInMonthTemporal.PlainYearMonth.prototype.monthsInYearTemporal.PlainDate.prototype.monthCode