Temporal.ZonedDateTime.prototype.weekOfYear
Temporal.ZonedDateTime 例項的 weekOfYear 訪問器屬性返回一個正整數,表示此日期在 yearOfWeek 中的基於 1 的周索引,如果日曆沒有明確定義的周系統,則返回 undefined。一年的第一週是 1。它取決於 日曆。
weekOfYear 的設定器是 undefined。你無法直接更改此屬性。要使用所需的新 weekOfYear 值建立新的 Temporal.ZonedDateTime 物件,請使用 add() 或 subtract() 方法並傳入適當的 weeks 數量。
有關一般資訊和更多示例,請參見 Temporal.PlainDate.prototype.weekOfYear。
示例
使用 weekOfYear
js
const dt = Temporal.ZonedDateTime.from("2021-07-01[America/New_York]");
console.log(dt.weekOfYear); // 26
規範
| 規範 |
|---|
| Temporal # sec-get-temporal.zoneddatetime.prototype.weekofyear |
瀏覽器相容性
載入中…
另見
Temporal.ZonedDateTimeTemporal.ZonedDateTime.prototype.with()Temporal.ZonedDateTime.prototype.add()Temporal.ZonedDateTime.prototype.subtract()Temporal.ZonedDateTime.prototype.yearOfWeekTemporal.ZonedDateTime.prototype.dayOfWeekTemporal.ZonedDateTime.prototype.daysInWeekTemporal.ZonedDateTime.prototype.daysInYearTemporal.PlainDate.prototype.weekOfYear