Temporal.PlainDateTime.prototype.monthCode
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 accessor monthCode của các instance Temporal.PlainDateTime trả về một chuỗi đặc trưng theo lịch đại diện cho tháng của ngày 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, là mã 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. Sử dụng phương thức with() để tạo một đối tượng Temporal.PlainDateTime mới với giá trị mới 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.PlainDateTime.from("2021-07-01"); // ISO 8601 calendar
console.log(date.monthCode); // "M07"
console.log(date.month); // 7
Đặc tả
| Thông số kỹ thuật |
|---|
| Temporal> # sec-get-temporal.plaindatetime.prototype.monthcode> |
Tương thích trình duyệt
Xem thêm
Temporal.PlainDateTimeTemporal.PlainDateTime.prototype.with()Temporal.PlainDateTime.prototype.add()Temporal.PlainDateTime.prototype.subtract()Temporal.PlainDateTime.prototype.yearTemporal.PlainDateTime.prototype.monthTemporal.PlainDateTime.prototype.daysInMonthTemporal.PlainDateTime.prototype.monthsInYearTemporal.PlainDate.prototype.monthCode