Temporal.PlainDate.prototype.daysInYear
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Thuộc tính accessor daysInYear của các instance Temporal.PlainDate trả về một số nguyên dương đại diện cho số ngày trong năm của ngày này. Nó phụ thuộc vào lịch.
Đối với lịch ISO 8601, đây là 365, hoặc 366 trong năm nhuận. Trong các hệ thống lịch khác, nó có thể khác nhau, đặc biệt trong các lịch không dựa trên mặt trời.
Set accessor của daysInWeek là undefined. Bạn không thể thay đổi thuộc tính này trực tiếp.
Ví dụ
>Sử dụng daysInYear
js
const date = Temporal.PlainDate.from("2021-07-01");
console.log(date.daysInYear); // 365
const date2 = Temporal.PlainDate.from("2020-07-01");
console.log(date2.daysInYear); // 366; 2020 là năm nhuận
const date3 = Temporal.PlainDate.from("2021-07-01[u-ca=chinese]");
console.log(date3.daysInYear); // 354
const date4 = Temporal.PlainDate.from("2023-07-01[u-ca=chinese]");
console.log(date4.daysInYear); // 384; 2023 là năm nhuận Trung Quốc
Đặc tả
| Specification |
|---|
| Temporal> # sec-get-temporal.plaindate.prototype.daysinyear> |