Temporal.PlainYearMonth.prototype.monthsInYear
monthsInYear 访问器属性是 Temporal.PlainYearMonth 实例的一个属性,它返回一个正整数,表示该日期所在年份的月份数。这个值 依赖于日历。
monthsInYear 的设置器为 undefined。你不能直接更改此属性。
有关一般信息和更多示例,请参阅Temporal.PlainDate.prototype.monthsInYear。
示例
使用 monthsInYear
js
const ym = Temporal.PlainYearMonth.from("2021-07");
console.log(ym.monthsInYear); // 12
规范
| 规范 |
|---|
| Temporal # sec-get-temporal.plainyearmonth.prototype.monthsinyear |
浏览器兼容性
加载中…
另见
Temporal.PlainYearMonthTemporal.PlainYearMonth.prototype.with()Temporal.PlainYearMonth.prototype.add()Temporal.PlainYearMonth.prototype.subtract()Temporal.PlainYearMonth.prototype.yearTemporal.PlainYearMonth.prototype.monthTemporal.PlainYearMonth.prototype.monthCodeTemporal.PlainYearMonth.prototype.daysInMonthTemporal.PlainDate.prototype.monthsInYear