Skip to content

Commit d7301b5

Browse files
committed
feat: Add separate time zone data for years 1970-2038
1 parent f5da47f commit d7301b5

File tree

8 files changed

+72
-10
lines changed

8 files changed

+72
-10
lines changed

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
.DS_Store
12
coverage
23
dist
34
node_modules
45
src/lookup/data*.js
5-
src/index-1900-2050.d.ts
6-
src/index-2012-2022.d.ts
7-
src/lookup/data-1900-2050.d.ts
8-
src/lookup/data-2012-2022.d.ts
6+
src/index-*.d.ts
7+
src/lookup/data-*.d.ts
98
test/browser
109
test/typings.test.js

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
.editorconfig
23
.gitignore
34
.npmignore

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Lightweight time zone listing and date converting. Intended for adding time zone
1313

1414
* Tiny code base - 4.6 KB minified, 1.7 KB gzipped. Do not pack unnecessary weight in your application.
1515
* Packed time zone data - 923 KB minified, 33.3 KB gzipped. Single time zones are unpacked on demand.
16-
* Smaller bundles with limited data - 1900-2050 (204 kB minified, 25.2 kB gzipped) and 2012-2022 (31.2 KB minified, 8.2 kB gzipped).
16+
* Smaller bundles with limited data - 1900-2050 (204 kB minified, 25.2 kB gzipped), 1970-2038 (204 kB minified, 25.2 kB gzipped) and 2012-2022 (31.2 KB minified, 8.2 kB gzipped).
1717
* Generated from the official time zone database version 2018g. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
1818
* Minimal interface for time zone lookup and conversions. Parsing, formatting and manipulating dates is usually the task for a higher-level date library.
1919

@@ -70,7 +70,7 @@ Functions are exposed as named exports from the package modules, for example:
7070
const { findTimeZone, getZonedTime } = require('timezone-support')
7171
```
7272

73-
You can read more about the [module loading](./docs/API.md#loading) in other environments, like with ES6 or in web browsers. [Usage scenarios](./docs/usage.md#usage-scenarios) demonstrate applications of this library in typical real-world scenarios. [Design concepts](./docs/design.md#design-concepts) explain the approach to time zone handling taken by tni library and types of values used ion the interface. Finally, the [API reference](./docs/API.md#api-reference) lists all functions with a description of their functionality.
73+
You can read more about the [module loading](./docs/API.md#loading) in other environments, like with ES6 or in web browsers. [Usage scenarios](./docs/usage.md#usage-scenarios) demonstrate applications of this library in typical real-world scenarios. [Design concepts](./docs/design.md#design-concepts) explain the approach to time zone handling taken by tni library and types of values used ion the interface. [Generating custom time zone data](./docs/usage.md#generate-custom-time-zone-data) will allow you to save the overall package size by limiting the supported year span. Finally, the [API reference](./docs/API.md#api-reference) lists all functions with a description of their functionality.
7474

7575
## Library Integrations
7676

@@ -83,6 +83,7 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.
8383

8484
## Release History
8585

86+
* 2018-11-17 v1.7.0 Include full time zone data separately and data for years 1970-2038.
8687
* 2018-11-06 v1.6.0 Upgrade the time zone database to the version 2018g.
8788
* 2018-10-08 v1.5.5 Fix compatibility with IE. Thanks, [Andrii](https://github.com/AndriiDidkivsky)!
8889
* 2018-10-06 v1.5.0 Add TypeScript export declarations.

docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ const data = {
355355
}
356356
```
357357

358-
See the [moment-timezone's latest data](../util/data/packed.json) as an example of the full data, which you can take a smaller part of to your application. This library includes [limited data for this decade](http://unpkg.com/timezone-support/dist/data-2012-2022.js) as an example. See also the script [wrap-limited-data](../util/wrap-limited-data.js), which produced the module with the limited data and which can be used to generate data for other time period too.
358+
See the [moment-timezone's latest data](../util/data/packed.json) as an example of the full data, which you can take a smaller part of to your application. This library includes [limited data for this decade](http://unpkg.com/timezone-support/dist/data-2012-2022.js) and [two other year spans](../src/lookup/). Read also abot [generation of custom time zone data](./usage.md#generate-custom-time-zone-data), which allows production of a module with smaller, limited time zone data for other time periods.
359359

360360
If this function is called later, than during the application startup, the behaviour of this module may be unpredictable. Some time zone data might be used and cached in the application. You should avoid re-initialization to prevent hidden errors.
361361

docs/usage.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The minimal, but powerful API of this module provides functionality for both dat
1313
- [Get UTC offset for a specific time zone](#get-utc-offset-for-a-specific-time-zone)
1414
- [Use the native Date object](#use-the-native-date-object)
1515
- [Limit the loaded time zone data](#limit-the-loaded-time-zone-data)
16+
- [Generate custom time zone data](#generate-custom-time-zone-data)
1617

1718
## List all available time zones
1819

@@ -175,7 +176,7 @@ If you process dates only from a limited time period, you can initialize this li
175176
```txt
176177
Full IANA TZ data: 923 KB minified, 33.3 KB gzipped
177178
Data for 1900-2050: 200 KB minified, 23.3 KB gzipped
178-
Data for 1970-2018: 106 KB minified, 13.1 KB gzipped
179+
Data for 1970-2038: 135 KB minified, 13.9 KB gzipped
179180
Data for 2012-2022: 27 KB minified, 6.5 KB gzipped
180181
```
181182

@@ -218,6 +219,7 @@ The following data modules ara published within this project:
218219
```txt
219220
dist/data.umd.js
220221
dist/data-1900-2050.umd.js
222+
dist/data-1970-2038.umd.js
221223
dist/data-2012-2022.umd.js
222224
```
223225

@@ -226,9 +228,12 @@ The following complete (code+data) modules ara published within this project:
226228
```txt
227229
dist/index.umd.js
228230
dist/index-1900-2050.umd.js
231+
dist/index-1970-2038.umd.js
229232
dist/index-2012-2022.umd.js
230233
```
231234

232235
See the function [populateTimeZones](./API.md#populatetimezones) for more information.
233236

237+
## Generate custom time zone data
238+
234239
[IANA time zone database]: https://www.iana.org/time-zones

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
"lint:fix": "standard --verbose --fix bin/create-timezone-data perf/*.js 'src/**/*.js' test/*.js util/*.js",
4343
"lint:js": "standard --verbose bin/create-timezone-data perf/*.js 'src/**/*.js' test/*.js util/*.js",
4444
"lint:ts": "tslint -t stylish src/*.ts src/lookup/*.ts test/*.ts",
45-
"generate": "bin/create-timezone-data -ma -o src/lookup/data.js && bin/create-timezone-data -m 2012 2022 -o src/lookup/data-2012-2022.js && bin/create-timezone-data -m 1900 2050 -o src/lookup/data-1900-2050.js",
45+
"generate": "bin/create-timezone-data -ma -o src/lookup/data.js && bin/create-timezone-data -m 2012 2022 -o src/lookup/data-2012-2022.js && bin/create-timezone-data -m 1900 2050 -o src/lookup/data-1900-2050.js && bin/create-timezone-data -m 1970 2038 -o src/lookup/data-1970-2038.js",
4646
"generate:browser-tests": "node util/generate-browser-tests",
4747
"compile": "rollup -c",
48-
"copy:typings": "cpy src/index.d.ts src --rename=index-2012-2022.d.ts && cpy src/index.d.ts src --rename=index-1900-2050.d.ts && cpy 'src/*.d.ts' dist && cpy src/lookup/data.d.ts src/lookup --rename=data-2012-2022.d.ts && cpy src/lookup/data.d.ts src/lookup --rename=data-1900-2050.d.ts && cpy 'src/lookup/*.d.ts' dist",
48+
"copy:typings": "cpy src/index.d.ts src --rename=index-2012-2022.d.ts && cpy src/index.d.ts src --rename=index-1970-2038.d.ts && cpy src/index.d.ts src --rename=index-1900-2050.d.ts && cpy 'src/*.d.ts' dist && cpy src/lookup/data.d.ts src/lookup --rename=data-2012-2022.d.ts && cpy src/lookup/data.d.ts src/lookup --rename=data-1970-2038.d.ts && cpy src/lookup/data.d.ts src/lookup --rename=data-1900-2050.d.ts && cpy 'src/lookup/*.d.ts' dist",
4949
"build": "run-s lint generate compile copy:typings",
5050
"compile:tests": "tsc --lib es6 test/typings.test.ts",
5151
"check": "jest --testPathIgnorePatterns \"browser.test.js\" --collectCoverage",

rollup.config.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ export default [
1414
clean()
1515
]
1616
},
17+
{
18+
input: 'src/index-1970-2038.js',
19+
output: {
20+
file: 'dist/index-1970-2038.js',
21+
format: 'cjs'
22+
},
23+
plugins: [
24+
babel({ exclude: 'node_modules/**' }),
25+
clean()
26+
]
27+
},
1728
{
1829
input: 'src/index-2012-2022.js',
1930
output: {
@@ -58,6 +69,17 @@ export default [
5869
clean()
5970
]
6071
},
72+
{
73+
input: 'src/lookup/data-1970-2038.js',
74+
output: {
75+
file: 'dist/data-1970-2038.js',
76+
format: 'cjs'
77+
},
78+
plugins: [
79+
babel({ exclude: 'node_modules/**' }),
80+
clean()
81+
]
82+
},
6183
{
6284
input: 'src/lookup/data-2012-2022.js',
6385
output: {
@@ -104,6 +126,19 @@ export default [
104126
uglify()
105127
]
106128
},
129+
{
130+
input: 'src/index-1970-2038.js',
131+
output: {
132+
file: 'dist/index-1970-2038.umd.js',
133+
format: 'umd',
134+
name: 'timezone-support',
135+
sourcemap: true
136+
},
137+
plugins: [
138+
babel({ exclude: 'node_modules/**' }),
139+
uglify()
140+
]
141+
},
107142
{
108143
input: 'src/index-2012-2022.js',
109144
output: {
@@ -156,6 +191,19 @@ export default [
156191
uglify()
157192
]
158193
},
194+
{
195+
input: 'src/lookup/data-1970-2038.js',
196+
output: {
197+
file: 'dist/data-1970-2038.umd.js',
198+
format: 'umd',
199+
name: 'timezone-data-1970-2038',
200+
sourcemap: true
201+
},
202+
plugins: [
203+
babel({ exclude: 'node_modules/**' }),
204+
uglify()
205+
]
206+
},
159207
{
160208
input: 'src/lookup/data-2012-2022.js',
161209
output: {

src/index-1970-2038.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {
2+
populateTimeZones, listTimeZones, findTimeZone, getUTCOffset, getZonedTime, getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
3+
} from './lookup-convert'
4+
import data from './lookup/data-1970-2038'
5+
6+
populateTimeZones(data)
7+
8+
export { listTimeZones, findTimeZone, getUTCOffset, getZonedTime, getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime }

0 commit comments

Comments
 (0)