IsoWeeksInYear
IsoWeeksInYear 外掛新增了 .isoWeeksInYear() API,用於回傳 number 型別,表示該年份的 ISO 週數。
TIP
此功能依賴於 IsLeapYear 外掛。
javascript
var isoWeeksInYear = require('dayjs/plugin/isoWeeksInYear');
// import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' // ES 2015
var isLeapYear = require('dayjs/plugin/isLeapYear'); // 依賴 isLeapYear 外掛
// import isLeapYear from 'dayjs/plugin/isLeapYear' // ES 2015
dayjs.extend(isoWeeksInYear);
dayjs.extend(isLeapYear);
dayjs('2004-01-01').isoWeeksInYear(); // 53
dayjs('2005-01-01').isoWeeksInYear(); // 52