Day.js 中文文档

当前版本 v1.11

更多文档

IsoWeeksInYear

IsoWeeksInYear 添加了 .isoWeeksInYear() API 以返回 number,以根据 ISO 周获取一年中的周数。

需要配合 IsLeapYear 插件才能工作

var isoWeeksInYear = require("dayjs/plugin/isoWeeksInYear");
// import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' // ES 2015

var isLeapYear = require("dayjs/plugin/isLeapYear"); // dependent on isLeapYear plugin
// 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

Day.js 中文文档 - 粤ICP备14034220号-1