有没有办法使用 Moment.js 来计算给定年份的 ISO 周数?

Is there a way to count number of ISO weeks in a given year using Moment.js?

我需要确定一年有多少个 ISO 周。

我的尝试是这样的

moment.tz(2019, "YYYY", "UTC").endOf("year").isoWeek()

但这不起作用。在某些情况下,12 月 31 日是 ISO 第 1 周。

Ofc,可能有一些丑陋的方法可以得到结果,但我想要一个干净的代码。

moment.js好像没有为此提供接口。

这似乎是解决方案(纯JS) Get weeks in year