diff --git a/README.md b/README.md index a23f4beec..f5baf11ad 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:m ```js // Load dayjs, plugins and language packs. import dayjs from 'dayjs-ext' -// import "timeZone-1900-2050" or "timeZone-2012-2022" to save your package size +// import "timeZone-1900-2050", "timeZone-1970-2038" +// or "timeZone-2012-2022" to save your package size import timeZonePlugin from 'dayjs-ext/plugin/timeZone' import customParseFormat from 'dayjs-ext/plugin/customParseFormat' import localizableFormat from 'dayjs-ext/plugin/localizableFormat' @@ -97,7 +98,8 @@ console.log(dateOnly.format({ format: 'YYYY-MM-DD' })) If used in the browser, the following scripts would be needed: ```html -<-- include "index-1900-2050" or "index-2012-2022" to save your package size --> +<-- include "index-1900-2050", "index-1970-2038" + or "index-2012-2022" to save your package size --> diff --git a/build/index.js b/build/index.js index 0dae426c0..93f7a41b5 100644 --- a/build/index.js +++ b/build/index.js @@ -35,7 +35,7 @@ async function build(option) { })) }) - const timeZoneVariants = ['custom', '1900-2050', '2012-2022'] + const timeZoneVariants = ['custom', '1900-2050', '1970-2038', '2012-2022'] timeZoneVariants.forEach((moduleName) => { build(configFactory({ input: `./src/plugin/timeZone/${moduleName}`, diff --git a/build/rollup.config.js b/build/rollup.config.js index 4f49cca3f..1d2c5a386 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -9,7 +9,7 @@ module.exports = (config) => { external: [ 'dayjs-ext', 'fast-plural-rules', 'timezone-support/dist/lookup-convert', 'timezone-support/dist/data', 'timezone-support/dist/data-1900-2050', - 'timezone-support/dist/data-2012-2022' + 'timezone-support/dist/data-1970-2038', 'timezone-support/dist/data-2012-2022' ], plugins: [ babel({ @@ -25,9 +25,10 @@ module.exports = (config) => { globals: { 'dayjs-ext': 'dayjs', 'fast-plural-rules': 'fastPluralRules', - 'timezone-support/dist/lookup-convert': 'timezone-support', + 'timezone-support/dist/lookup-convert': 'timezone-lookup-convert', 'timezone-support/dist/data': 'timezone-data', 'timezone-support/dist/data-1900-2050': 'timezone-data-1900-2050', + 'timezone-support/dist/data-1970-2038': 'timezone-data-1970-2038', 'timezone-support/dist/data-2012-2022': 'timezone-data-2012-2022' }, sourcemap: true diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index 6cc47109d..4ec0bf65e 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -245,7 +245,8 @@ If the plugin [LocalizableFormat](#localizableformat) is installed, format token - TimeZone extends `dayjs()` and `dayjs().format` APIs to support the most important usage scenatrios - parsing from a specific time zone and formatting in other time zone. ```javascript -// import "timeZone-1900-2050" or "timeZone-2012-2022" to save your package size +// import "timeZone-1900-2050", "timeZone-1970-2038" +// or "timeZone-2012-2022" to save your package size import timeZone from 'dayjs-ext/plugin/timeZone' dayjs.extend(timeZone) @@ -284,10 +285,11 @@ The plugin includes all available time zone data in the main module `dayjs-ext/p ```txt Full IANA TZ data: 923 KB minified, 33.3 KB gzipped Data for 1900-2050: 200 KB minified, 23.3 KB gzipped +Data for 1970-2038: 135 KB minified, 13.9 KB gzipped Data for 2012-2022: 27 KB minified, 6.5 KB gzipped ``` -Modules with limited time zone data are exposed as `dayjs-ext/plugin/timeZone-1900-2050` and `dayjs-ext/plugin/timeZone-2012-2022`. A custom module with different time zone data can be used via `dayjs-ext/plugin/timeZone-custom`: +Modules with limited time zone data are exposed as `dayjs-ext/plugin/timeZone-1900-2050`, `dayjs-ext/plugin/timeZone-1970-2038` and `dayjs-ext/plugin/timeZone-2012-2022`. A custom module with different time zone data can be used via `dayjs-ext/plugin/timeZone-custom`: ```js import dayjs from 'dayjs-ext' @@ -308,7 +310,8 @@ When `dayjs-ext` is loaded in the browser as described below, custom data can be This plugin has a dependency on the [`timezone-support`](https://www.npmjs.com/package/timezone-support) NPM module. If you are going to use it on a web page directly, add its script to your section of ` diff --git a/package-lock.json b/package-lock.json index 26f5af727..b83ac1c0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10681,9 +10681,9 @@ } }, "timezone-support": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/timezone-support/-/timezone-support-1.7.0.tgz", - "integrity": "sha512-Jeci8AUmrDj7Fz+g8T2hG636i3oL5PgXusprAspYJTE2Jt1Bl1PSTlJ1fY6S69ixyw2pTFgcazPcVe8cyouvpw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/timezone-support/-/timezone-support-1.8.0.tgz", + "integrity": "sha512-eGoH5aDwLOqgTzCRzpBJMuGgqEMn7SJz7wbHf8T8ADwxH9t24HT8aLIw+WksPIFe7Ou561cx9GEsBa6vuSEf7g==", "requires": { "commander": "2.19.0" } diff --git a/package.json b/package.json index 5a8be0559..6ebe2f48f 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,8 @@ "plugin/timeZone-custom.js.map", "plugin/timeZone-1900-2050.js", "plugin/timeZone-1900-2050.js.map", + "plugin/timeZone-1970-2038.js", + "plugin/timeZone-1970-2038.js.map", "plugin/timeZone-2012-2022.js", "plugin/timeZone-2012-2022.js.map", "plugin/weekOfYear.js", @@ -158,7 +160,7 @@ }, "dependencies": { "fast-plural-rules": "^0.0.1", - "timezone-support": "^1.7.0" + "timezone-support": "^1.8.0" }, "devDependencies": { "@babel/cli": "^7.1.5", diff --git a/src/plugin/timeZone/1970-2038.js b/src/plugin/timeZone/1970-2038.js new file mode 100644 index 000000000..0a567d3c0 --- /dev/null +++ b/src/plugin/timeZone/1970-2038.js @@ -0,0 +1,6 @@ +import { populateTimeZones } from 'timezone-support/dist/lookup-convert' +import timeZoneData from 'timezone-support/dist/data-1970-2038' + +populateTimeZones(timeZoneData) + +export { default } from './custom'