我想在我的 js 文件中使用 moment.js 从一个时区转换为另一个时区。我想知道下面的文字是什么意思?
For convenience, there are builds available on momentjs.com/timezone/ with all the zone data or a subset of the data with support for only 2012-2022.
这是否意味着 moment.js
仅在日期介于 2012-2022 之间时才支持时区之间的转换?
最佳答案
如果您的需求介于这些年份之间,请使用“2010-2020”文件,它轻巧且速度更快。
现在回答你的问题:
Does that mean moment.js supports conversion between timezones only if the date lies between 2012- 2022 ?
答案是是 2012- 2022文件包含 2012-2022 之间的数据。但这并不意味着main file不包含 2012-2022 年的数据。该文件也包含数据,但比 moment-timezone-with-data-2012-2022.js
解释:
这两个不同文件的原因是 moment-timezone 的数据不包含同比规则,而是包含给定年份范围内的特定转换。
在运行时进行更快的查找,但代价是必须决定要使用的数据子集。
“所有年份”文件包含过去所有已知的过渡,以及大约 20 年的 future 过渡。 “2010-2020”文件仅包含近期和近期。
关于javascript - 2012-2020年的矩数据是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50109908/