javascript - momentjs 如何使时区数据保持最新
问题描述
由于时区数据会发生变化,尤其是夏令时规则,momentjs 如何及时了解这些信息?
如果我将 momentjs-timezone 用于依赖于时区的调度系统,我是否需要进行任何维护以使时区数据保持最新?如果 momentjs 自动管理这个,它是如何做到的?
解决方案
From the moment-timezone docs:
The data for Moment Timezone comes from the IANA Time Zone Database. New versions are released periodically as time zone laws change in various countries.
The versions are named after the year and an incrementing letter. 2014a 2014b 2014c...
In order to keep versions together, Moment Timezone has a bundled object format as well.
You can access both the moment.tz version and data version:
const moment = require("moment-timezone");
console.log(`moment.version: ${moment.tz.version}`);
console.log(`moment.dataVersion: ${moment.tz.dataVersion}`);
This will look like:
moment.version: 0.5.33
moment.dataVersion: 2021a
You can see from the dataVersion how up to date the timezone data is and whether it needs updating.
You will need to update your installed version using npm / yarn to get any timezone changes.
推荐阅读
- javascript - 如何使用 image-js 和 JavaScript 标准化图像(直方图拉伸)?
- jupyter-notebook - 如何执行不同大小的相关性
- database - 多次加入日期维度?- Kimball 关于数据仓库和维度建模的书
- flutter - 自动选择圆形列表颤振中的项目
- python - 如何使用 while 循环来检测列表中是否已提供客户 ID?
- html - pdf文件无法从网页下载
- flutter - 颤振安装
- python - 为什么`filter`适用于一个列表而不适用于其他给出“具有多个元素的数组的真值是不明确的。”?
- list - 迁移时忽略列表项
- python-3.x - 从另一个项目导入模型