Skip to content

Commit a58e7d3

Browse files
committed
docs: Update documentation
1 parent 57b36d8 commit a58e7d3

4 files changed

Lines changed: 62 additions & 12 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
Lightweight time zone listing and date converting. Intended for adding time zone support to high-level date libraries, but also for direct application usage.
1313

14-
* Tiny code base - 3.5 KB minified, 1.5 KB gzipped. Do not pack unnecessary weight in your application.
15-
* Packed time zone data - 178 KB minified, 22.5 KB gzipped. Single time zones are unpacked on demand.
16-
* Even smaller version with limited, 2012-2022 timezone data - 31 KB minified, 8K gzipped.
17-
* Generated from the official time zone database version 2018e. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
14+
* Tiny code base - 4.6 KB minified, 1.7 KB gzipped. Do not pack unnecessary weight in your application.
15+
* 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).
17+
* 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

2020
### Table of Contents
@@ -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-06 v1.6.0 Upgrade the time zone database to the version 2018g.
8687
* 2018-10-08 v1.5.5 Fix compatibility with IE. Thanks, [Andrii](https://github.com/AndriiDidkivsky)!
8788
* 2018-10-06 v1.5.0 Add TypeScript export declarations.
8889
* 2018-09-30 v1.4.0 Add limited data for just the current decade - years 2012-2022.

docs/API.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Load the main module in the browser with plain JavaScript:
4949
</script>
5050
```
5151

52-
You can also load a specific version from CDN, for example: https://unpkg.com/timezone-support@1.5.5/dist/index.umd.js.
52+
You can also load a specific version from CDN, for example: https://unpkg.com/timezone-support@1.6.0/dist/index.umd.js.
5353

5454
## Modules
5555

@@ -430,5 +430,34 @@ const berlinTime = setTimeZone(date, berlin, { useUTC: true })
430430

431431
`Date` objects in the last two scenarios are initialized only for formatting or conversion purposes, because other methods, than the date part getters, deliver wrong results. Such "invalid" `Date` instances should exist only temporarily in a restricted scope. They should not be shared widely in the application to prevent mistakes from happening. The local time in a valid `Date` object has to match the UTC time maintained by the same object.
432432

433+
## Data Generator
434+
435+
If you want to [limit the time zone data](#limit-the-loaded-time-zone-data) to improve performance of your application by reducing the size of the JavaScript code, you can use the command-line tool included in this package:
436+
437+
```txt
438+
Usage: create-timezone-data [options] <first year> <last year>
439+
440+
Options:
441+
-V, --version output the version number
442+
-a, --all-years includes all available years
443+
-c, --as-cjs-module format the time zone data as a CommonJS module
444+
-d, --as-amd-module format the time zone data as an AMD module
445+
-m, --as-module format the time zone data as a JavaScript module
446+
-n, --umd-name UMD global export name, if not "timeZoneData"
447+
-o, --output-file <file> write the time zone data to a file
448+
-u, --as-umd-module format the time zone data as an UMD module
449+
-o, --output-file <file> write the time zone data to a file
450+
-h, --help output usage information
451+
452+
Time zone data are printed on the standard output as JSON by default.
453+
454+
Examples:
455+
456+
$ create-timezone-data 2012 2022
457+
$ create-timezone-data -m -o custom-data.js 1970 2038
458+
```
459+
460+
The module generated by this tool exposes a data object as a default export, which is expected bu the function[populatePluralData](#populatepluraldata).
461+
433462
[time object]: ./design.md#time-object
434463
[IANA time zones]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

docs/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The purpose of this library is to offer an efficient support for time zone handl
44

55
* Lightweight - nothing else is included. Thus serving well for other date & time libraries, but also for applications, which do not manipulate dates.
66
* Tiny - use packed time zone data, unpacked on demand. Compromise between loading time and being ready to use immediately.
7-
* Reliable - generated from the fresh official time zone database version 2018e. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
7+
* Reliable - generated from the fresh official time zone database version 2018g. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
88
* Customizable - named exports and functions divided to separate modules allow tree-shaking. Alternative time zone data can be supplied to reduce the library size.
99

1010
### Table of Contents

docs/usage.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,20 @@ See the functions [convertDateToTime](./API.md#convertdatetotime) and [convertTi
170170

171171
## Limit the loaded time zone data
172172

173-
The full time zone data cover all dates between 1970 and 2018. If you process dates only from a limited time period, you can initialize this library with a subset of time zone data and decrease the loading time of your application. For example, the difference between the full time zone data and the data for this decade only:
173+
If you process dates only from a limited time period, you can initialize this library with a subset of the [IANA time zone database] and decrease the loading time of your application. For example, the difference between the full time zone data and the data for this decade only:
174174

175-
```
176-
Data for 1970-2018: 178 KB minified, 22.5 KB gzipped
175+
```txt
176+
Full IANA TZ data: 923 KB minified, 33.3 KB gzipped
177+
Data for 1900-2050: 200 KB minified, 23.3 KB gzipped
178+
Data for 1970-2018: 106 KB minified, 13.1 KB gzipped
177179
Data for 2012-2022: 27 KB minified, 6.5 KB gzipped
178180
```
179181

180182
Custom time zone data can be used if the module `lookup-convert` is loaded instead of the default `index` module.
181183

182184
```html
183-
<script src="https://unpkg.com/timezone-support@1.5.5/dist/lookup-convert.umd.js"></script>
184-
<script src="https://unpkg.com/timezone-support@1.5.5/dist/data-2012-2022.umd.js"></script>
185+
<script src="https://unpkg.com/timezone-support@1.6.0/dist/lookup-convert.umd.js"></script>
186+
<script src="https://unpkg.com/timezone-support@1.6.0/dist/data-2012-2022.umd.js"></script>
185187
<script>
186188
(() => {
187189
const { populateTimeZones, findTimeZone, getZonedTime } = window['timezone-lookup-convert']
@@ -199,7 +201,7 @@ Custom time zone data can be used if the module `lookup-convert` is loaded inste
199201
If you want to use the time zone data for years 2012-2022 published by this project, you can simplify your code by using a bundled package with both data and code.
200202

201203
```html
202-
<script src="https://unpkg.com/timezone-support@1.5.5/dist/index-2012-2022.umd.js"></script>
204+
<script src="https://unpkg.com/timezone-support@1.6.0/dist/index-2012-2022.umd.js"></script>
203205
<script>
204206
(() => {
205207
const { findTimeZone, getZonedTime } = window['timezone-support']
@@ -211,4 +213,22 @@ If you want to use the time zone data for years 2012-2022 published by this proj
211213
</script>
212214
```
213215

216+
The following data modules ara published within this project:
217+
218+
```txt
219+
dist/data.umd.js
220+
dist/data-1900-2050.umd.js
221+
dist/data-2012-2022.umd.js
222+
```
223+
224+
The following complete (code+data) modules ara published within this project:
225+
226+
```txt
227+
dist/index.umd.js
228+
dist/index-1900-2050.umd.js
229+
dist/index-2012-2022.umd.js
230+
```
231+
214232
See the function [populateTimeZones](./API.md#populatetimezones) for more information.
233+
234+
[IANA time zone database]: https://www.iana.org/time-zones

0 commit comments

Comments
 (0)