Skip to content

Commit 2e5ec2d

Browse files
committed
feat: Add time zone data module for years 1970-2038
1 parent bc12675 commit 2e5ec2d

File tree

7 files changed

+26
-12
lines changed

7 files changed

+26
-12
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:m
5252
```js
5353
// Load dayjs, plugins and language packs.
5454
import dayjs from 'dayjs-ext'
55-
// import "timeZone-1900-2050" or "timeZone-2012-2022" to save your package size
55+
// import "timeZone-1900-2050", "timeZone-1970-2038"
56+
// or "timeZone-2012-2022" to save your package size
5657
import timeZonePlugin from 'dayjs-ext/plugin/timeZone'
5758
import customParseFormat from 'dayjs-ext/plugin/customParseFormat'
5859
import localizableFormat from 'dayjs-ext/plugin/localizableFormat'
@@ -97,7 +98,8 @@ console.log(dateOnly.format({ format: 'YYYY-MM-DD' }))
9798
If used in the browser, the following scripts would be needed:
9899

99100
```html
100-
<-- include "index-1900-2050" or "index-2012-2022" to save your package size -->
101+
<-- include "index-1900-2050", "index-1970-2038"
102+
or "index-2012-2022" to save your package size -->
101103
<script arc="https://unpkg.com/timezone-support/dist/index.umd.js"></script>
102104
<script arc="https://unpkg.com/fast-plural-rules/dist/index.umd.js"></script>
103105
<script arc="https://unpkg.com/dayjs-ext/dayjs.min.js"></script>

build/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function build(option) {
3535
}))
3636
})
3737

38-
const timeZoneVariants = ['custom', '1900-2050', '2012-2022']
38+
const timeZoneVariants = ['custom', '1900-2050', '1970-2038', '2012-2022']
3939
timeZoneVariants.forEach((moduleName) => {
4040
build(configFactory({
4141
input: `./src/plugin/timeZone/${moduleName}`,

build/rollup.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = (config) => {
99
external: [
1010
'dayjs-ext', 'fast-plural-rules', 'timezone-support/dist/lookup-convert',
1111
'timezone-support/dist/data', 'timezone-support/dist/data-1900-2050',
12-
'timezone-support/dist/data-2012-2022'
12+
'timezone-support/dist/data-1970-2038', 'timezone-support/dist/data-2012-2022'
1313
],
1414
plugins: [
1515
babel({
@@ -25,9 +25,10 @@ module.exports = (config) => {
2525
globals: {
2626
'dayjs-ext': 'dayjs',
2727
'fast-plural-rules': 'fastPluralRules',
28-
'timezone-support/dist/lookup-convert': 'timezone-support',
28+
'timezone-support/dist/lookup-convert': 'timezone-lookup-convert',
2929
'timezone-support/dist/data': 'timezone-data',
3030
'timezone-support/dist/data-1900-2050': 'timezone-data-1900-2050',
31+
'timezone-support/dist/data-1970-2038': 'timezone-data-1970-2038',
3132
'timezone-support/dist/data-2012-2022': 'timezone-data-2012-2022'
3233
},
3334
sourcemap: true

docs/en/Plugin.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ If the plugin [LocalizableFormat](#localizableformat) is installed, format token
245245
- 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.
246246

247247
```javascript
248-
// import "timeZone-1900-2050" or "timeZone-2012-2022" to save your package size
248+
// import "timeZone-1900-2050", "timeZone-1970-2038"
249+
// or "timeZone-2012-2022" to save your package size
249250
import timeZone from 'dayjs-ext/plugin/timeZone'
250251

251252
dayjs.extend(timeZone)
@@ -284,10 +285,11 @@ The plugin includes all available time zone data in the main module `dayjs-ext/p
284285
```txt
285286
Full IANA TZ data: 923 KB minified, 33.3 KB gzipped
286287
Data for 1900-2050: 200 KB minified, 23.3 KB gzipped
288+
Data for 1970-2038: 135 KB minified, 13.9 KB gzipped
287289
Data for 2012-2022: 27 KB minified, 6.5 KB gzipped
288290
```
289291

290-
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`:
292+
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`:
291293

292294
```js
293295
import dayjs from 'dayjs-ext'
@@ -308,7 +310,8 @@ When `dayjs-ext` is loaded in the browser as described below, custom data can be
308310
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 `<script>`s too, along with the `Day.js`, for example:
309311

310312
```html
311-
<-- include "index-1900-2050.umd.js" or "index-2012-2022.umd.js" to save your package size -->
313+
<-- include "index-1900-2050.umd.js", "index-1970-2038.umd.js"
314+
or "index-2012-2022.umd.js" to save your package size -->
312315
<script arc="https://unpkg.com/timezone-support/dist/index.umd.js"></script>
313316
<script arc="https://unpkg.com/dayjs-ext/dayjs.min.js"></script>
314317
<script arc="https://unpkg.com/dayjs-ext/plugin/timeZone.js"></script>

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
"plugin/timeZone-custom.js.map",
8585
"plugin/timeZone-1900-2050.js",
8686
"plugin/timeZone-1900-2050.js.map",
87+
"plugin/timeZone-1970-2038.js",
88+
"plugin/timeZone-1970-2038.js.map",
8789
"plugin/timeZone-2012-2022.js",
8890
"plugin/timeZone-2012-2022.js.map",
8991
"plugin/weekOfYear.js",
@@ -158,7 +160,7 @@
158160
},
159161
"dependencies": {
160162
"fast-plural-rules": "^0.0.1",
161-
"timezone-support": "^1.7.0"
163+
"timezone-support": "^1.8.0"
162164
},
163165
"devDependencies": {
164166
"@babel/cli": "^7.1.5",

src/plugin/timeZone/1970-2038.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { populateTimeZones } from 'timezone-support/dist/lookup-convert'
2+
import timeZoneData from 'timezone-support/dist/data-1970-2038'
3+
4+
populateTimeZones(timeZoneData)
5+
6+
export { default } from './custom'

0 commit comments

Comments
 (0)