isocalendar


npm install moment-isocalendar

如果你正在寻找类似 Python 的 isocalendar 方法,则可以使用 Rocky Meza 的插件

moment-isocalendar

在 moment 上调用 isocalendar 方法将会返回如下数组:

[year, week_of_year, day_of_week, minutes_since_midnight]

moment().isocalendar(); // [2012, 8, 5, 870]

还可以从 isocalendar 数组重造 moment。

moment.fromIsocalendar([2011, 51, 5, 870]).format('LLLL');
// "Friday, December 23 2011 2:30 PM"

该仓库位于 github.com/fusionbox/moment-isocalendar

npm install moment-isocalendar

If you are looking for a Python-like isocalendar method, you can use Rocky Meza's plugin

moment-isocalendar

Calling the isocalendar method on a moment will return an array like the following:

[year, week_of_year, day_of_week, minutes_since_midnight]

moment().isocalendar(); // [2012, 8, 5, 870]

You can also reconstruct a moment from a isocalendar array.

moment.fromIsocalendar([2011, 51, 5, 870]).format('LLLL');
// "Friday, December 23 2011 2:30 PM"

The repository is located at github.com/fusionbox/moment-isocalendar.