timezones-ical-library 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +39 -0
- package/.prettierignore +8 -0
- package/.prettierrc.json +8 -0
- package/.stylelintrc.json +8 -0
- package/Readme.md +49 -27
- package/api/zones.json +597 -0
- package/dist/tzlib.js +1433 -637
- package/index.d.ts +3 -12
- package/npm_dist/cjs/.eslintrc.json +1 -0
- package/npm_dist/cjs/index.js +1433 -637
- package/npm_dist/mjs/index.js +1433 -637
- package/package.json +19 -3
- package/dist/tzlib.min.js +0 -2
- package/dist/tzlib.min.js.map +0 -1
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"browser": true,
|
|
5
|
+
"es2021": true
|
|
6
|
+
},
|
|
7
|
+
"extends": [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended",
|
|
10
|
+
"plugin:security/recommended",
|
|
11
|
+
"prettier"
|
|
12
|
+
],
|
|
13
|
+
"parser": "@typescript-eslint/parser",
|
|
14
|
+
"parserOptions": {
|
|
15
|
+
"ecmaVersion": "latest",
|
|
16
|
+
"sourceType": "module",
|
|
17
|
+
"xss/no-mixed-html": [
|
|
18
|
+
2,
|
|
19
|
+
{
|
|
20
|
+
"functions": {
|
|
21
|
+
".encodeURIComponent": {
|
|
22
|
+
"passthrough": { "obj": true, "args": true }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"plugins": ["@typescript-eslint"],
|
|
29
|
+
"ignorePatterns": [
|
|
30
|
+
"*.min.*",
|
|
31
|
+
"Gruntfile.js",
|
|
32
|
+
"zonesdb.js",
|
|
33
|
+
"generator.js",
|
|
34
|
+
"set-release.js",
|
|
35
|
+
"npm_dist/",
|
|
36
|
+
"dist/"
|
|
37
|
+
],
|
|
38
|
+
"rules": {}
|
|
39
|
+
}
|
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
package/Readme.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Add to Calendar TimeZones iCal Library
|
|
6
6
|
|
|
7
|
-
The tool to convert the [IANA (formerly Olson)
|
|
7
|
+
The tool to convert the [IANA (formerly Olson) time zone database files](http://www.iana.org/time-zones) into VTIMEZONE blocks, compatible with the iCalendar specification (RFC2445).
|
|
8
8
|
|
|
9
9
|
It is based on the awesome tool by Damon Chaplin ([github.com/libical/vzic](https://github.com/libical/vzic)), but only provides the VTIMEZONE part to easily put this into any other iCal generator (like the [add-to-calendar-button](https://github.com/add2cal/add-to-calendar-button)). It is built to be used standalone or as JavaScript module, hosted as npm package.
|
|
10
10
|
|
|
@@ -18,37 +18,28 @@ It is based on the awesome tool by Damon Chaplin ([github.com/libical/vzic](http
|
|
|
18
18
|
|
|
19
19
|
### 0. Update it (not required)
|
|
20
20
|
|
|
21
|
-
**This step is only relevant if you want to build the package and data from source!**
|
|
22
|
-
|
|
21
|
+
**This step is only relevant if you want to build the package and data on your own and from source!**
|
|
22
|
+
_(Requires Node.js as well as Linux as operating system.)_
|
|
23
23
|
Run ...
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
sudo sh update-tzdata.sh tzVersionNumber
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
... with
|
|
29
|
+
... with _tzVersionNumber_ being the version of the IANA time zone database you want to use (e.g. sudo sh update-tzdata.sh 2022d).
|
|
30
30
|
|
|
31
31
|
<br />
|
|
32
32
|
|
|
33
33
|
### 1. Load it
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
You can use the pure and simple version directly from the dist folder or the jsDelivr CDN and include in your application:
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
<script src="https://cdn.jsdelivr.net/npm/timezones-ical-library"></script>
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
#### B. npm package
|
|
44
|
-
|
|
45
|
-
Alternatively, you can install the package via npm with:
|
|
35
|
+
Install the package via npm with:
|
|
46
36
|
|
|
47
37
|
```
|
|
48
38
|
npm install timezones-ical-library
|
|
49
39
|
```
|
|
50
40
|
|
|
51
41
|
After the installation:
|
|
42
|
+
|
|
52
43
|
- require the package (commonJS) or ...
|
|
53
44
|
- import the module (ES) via `import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'timezones-ical-library';`.
|
|
54
45
|
|
|
@@ -56,13 +47,13 @@ After the installation:
|
|
|
56
47
|
|
|
57
48
|
### 2. Use it
|
|
58
49
|
|
|
59
|
-
#### A. Get
|
|
50
|
+
#### A. Get time zones
|
|
60
51
|
|
|
61
|
-
Use `tzlib_get_timezones()` to retrieve a list of all available
|
|
52
|
+
Use `tzlib_get_timezones()` to retrieve a list of all available time zone strings. You can pass `true` to retrieve a JSON formatted string instead of an array.
|
|
62
53
|
|
|
63
|
-
#### B. Get the iCal
|
|
54
|
+
#### B. Get the iCal time zone block
|
|
64
55
|
|
|
65
|
-
Use the `tzlib_get_ical_block(tzName)` function to return the proper iCal VTIMEZONE block for a given
|
|
56
|
+
Use the `tzlib_get_ical_block(tzName)` function to return the proper iCal VTIMEZONE block for a given time zone string (tzName). Again, pass `true` to retrieve a JSON formatted string instead of an array (not recommended).
|
|
66
57
|
|
|
67
58
|
You will receive an array, holding the VTIMEZONE block first, and the TZID line (additionally) second. The latter one is needed for any further time statement.
|
|
68
59
|
|
|
@@ -79,7 +70,7 @@ CALSCALE:GREGORIAN
|
|
|
79
70
|
|
|
80
71
|
```
|
|
81
72
|
BEGIN:VTIMEZONE
|
|
82
|
-
TZID
|
|
73
|
+
TZID:America/New_York
|
|
83
74
|
LAST-MODIFIED:20220824T133813Z
|
|
84
75
|
X-LIC-LOCATION:America/New_York
|
|
85
76
|
BEGIN:DAYLIGHT
|
|
@@ -103,8 +94,8 @@ END:VTIMEZONE
|
|
|
103
94
|
BEGIN:VEVENT
|
|
104
95
|
UID:2022-08-30T19:29:38.618Z@add-to-calendar-button
|
|
105
96
|
DTSTAMP:20230214T091500Z
|
|
106
|
-
DTSTART;TZID
|
|
107
|
-
DTEND;TZID
|
|
97
|
+
DTSTART;TZID=America/New_York:20230214T091500
|
|
98
|
+
DTEND;TZID=America/New_York:20230218T223000
|
|
108
99
|
SUMMARY:A sample event
|
|
109
100
|
DESCRIPTION:Just some descriptive text...
|
|
110
101
|
LOCATION:World Wide Web
|
|
@@ -119,7 +110,34 @@ END:VCALENDAR
|
|
|
119
110
|
|
|
120
111
|
Use `tzlib_get_offset(tzName, isoDate, isoTime)` to get specific offset (relative to UTC), based on a provided date and time.
|
|
121
112
|
|
|
122
|
-
For example, you can provide
|
|
113
|
+
For example, you can provide _tzName_ `'Europe/Berlin'`, _isoDate_ `'2023-05-23'`, and _isoTime_ `'15:45'` in order to retrieve the offset, which applies for this time zone at the 23rd of May in 2023 at exactly 15:45.
|
|
114
|
+
|
|
115
|
+
<br /><br />
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
<br />
|
|
120
|
+
|
|
121
|
+
## ⚙️ API
|
|
122
|
+
|
|
123
|
+
Instead of using this code or the npm package, you could also make use of the free and open API.
|
|
124
|
+
|
|
125
|
+
### Getting a list of all zone names
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
https://tz.add-to-calendar-technology.com/api/zones.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Getting the ics part of a respective zone
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
https://tz.add-to-calendar-technology.com/api/%zoneName%.ics
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
With %zoneName% being your time zone. So, for New York, this would be [https://tz.add-to-calendar-technology.com/api/America/New_York.ics](https://tz.add-to-calendar-technology.com/api/America/New_York.ics).
|
|
138
|
+
**This is case sensitive!**
|
|
139
|
+
|
|
140
|
+
(Mind that this does not deliver a fully valid ics file, since it only contains the VTIMEZONE part. You will need to combine this with your other event information.)
|
|
123
141
|
|
|
124
142
|
<br /><br />
|
|
125
143
|
|
|
@@ -139,12 +157,16 @@ Anyone is welcome to contribute, but mind the [guidelines](.github/CONTRIBUTING.
|
|
|
139
157
|
|
|
140
158
|
## 📃 Copyright and License
|
|
141
159
|
|
|
160
|
+
Copyright (c) [Jens Kuerschner](https://jenskuerschner.de).
|
|
161
|
+
|
|
142
162
|
Licensed under [Apache-2.0](LICENSE).
|
|
143
163
|
|
|
144
164
|
<br />
|
|
145
165
|
|
|
146
166
|
## ⚡ Changelog (without minor changes and fixes)
|
|
147
167
|
|
|
168
|
+
- v1.3 : bundle size optimization and API
|
|
169
|
+
- v1.2 : providing tzblock as array with separate tzid
|
|
148
170
|
- v1.1 : get-offset function
|
|
149
171
|
- v1.0 : initial release
|
|
150
172
|
|
|
@@ -154,7 +176,7 @@ Licensed under [Apache-2.0](LICENSE).
|
|
|
154
176
|
|
|
155
177
|
## 💜 Kudos go to
|
|
156
178
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
179
|
+
- The ["Time Zone King"](https://samueli.ucla.edu/time-zone-king-how-one-ucla-computer-scientist-keeps-digital-clocks-ticking/) [Paul Eggert](https://github.com/eggert) for optimizing time zones for the web, ...
|
|
180
|
+
- as well as all the contributors at [the official tz repository](https://github.com/eggert/tz).
|
|
181
|
+
- The awesome authors of zic and [vzic](https://github.com/libical/vzic/graphs/contributors); mainly Damon Chaplin, [Allen Winter](https://github.com/winterz), and [Ken Murchison](https://github.com/ksmurchison).
|
|
182
|
+
- [Trevor Eyre](https://github.com/trevoreyre) for his smooth and beautiful [autocomplete script](https://github.com/trevoreyre/autocomplete).
|