Skip to content

Commit

Permalink
Dev (#11)
Browse files Browse the repository at this point in the history
* minor descriptive updates

* data update

* readme + test updates

* font and text update

* font preload update

* font size update
  • Loading branch information
jekuer committed Aug 30, 2022
1 parent 3350b83 commit 73c43c8
Show file tree
Hide file tree
Showing 403 changed files with 2,141 additions and 2,000 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tzDbContent = fs.readFileSync('./src/zonesdb.js', 'utf-8');
function prepareFinalFile(content, exportPhrase = '') {
let newContent = content.replace(tzDbPlaceholder, tzDbContent);
if (exportPhrase != '') {
newContent = newContent.replace(exportCodePlaceholder, `${exportPhrase} { tzlib_get_ical_block };`);
newContent = newContent.replace(exportCodePlaceholder, `${exportPhrase} { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones };`);
} else {
newContent = newContent.replace(exportCodePlaceholder, '');
}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OLSON_DIR ?= tzdata
# gets expanded to today's date. There is also a vzic-merge.pl which can be
# used to merge changes into a master set of VTIMEZONEs. If a VTIMEZONE has
# changed, it bumps the version number on the end of this prefix. */
TZID_PREFIX ?= /add-to-calendar-pro.com/%D/
TZID_PREFIX ?= /timezones-ical-library/%D/

#
# You shouldn't need to change the rest of the file.
Expand Down
101 changes: 86 additions & 15 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,109 @@ It is based on the awesome tool by Damon Chaplin ([github.com/libical/vzic](http

## 📦 Installation / Setup

### 1. Update it
### 0. Update it (not required)

**This step is only relevant if you want to build the package from source!**

(Requires Node.js as well as Linux as operating system.)

Run
**This step is only relevant if you want to build the package and data from source!**
*(Requires Node.js as well as Linux as operating system.)*
Run ...

```
sudo sh update-tzdata.sh tzVersionNumber
```

with *tzVersionNumber* being the version of the timezone database you want to use (e.g. sudo sh update-tzdata.sh 2022c).
... with *tzVersionNumber* being the version of the IANA timezone database you want to use (e.g. sudo sh update-tzdata.sh 2022c).

<br />

### 2. Load it

There are basically 2 options how you can use the script.
### 1. Load it

#### A. VanillaJS

You can use the VanillaJS version from the dist folder or simply the jsDelivr CDN:
You can use the pure and simple version directly from the dist folder or the jsDelivr CDN and include in your application:

```
<script src="https://cdn.jsdelivr.net/npm/timzones-ical-library"></script>
```

#### B. npm package

Alternatively, you can install the package via npm with:

```
npm install timezones-ical-library
```

After the installation, you can then either ...
After the installation:
- require the package (commonJS) or ...
- import the module (ES) via `import { tzlib_get_ical_block } from 'timezones-ical-library';`.
- import the module (ES) via `import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'timezones-ical-library';`.

### 3. Use it
<br />

### 2. Use it

Use `tzlib_get_ical_block(tzName)` function to return the proper iCal VTIMEZONE block for a given timezone string (tzName).
#### A. Get timezones

Use `tzlib_get_timezones()` to retrieve a list of all available timezone strings. You can pass `true` to retrieve a JSON formatted string instead of an array.

#### B. Get the iCal timezone block

Use the `tzlib_get_ical_block(tzName)` function to return the proper iCal VTIMEZONE block for a given timezone string (tzName).

Include this into your further iCal data to come up with a complete ics file.

A final constellation could look like this:

```
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-// github.com/add2cal/add-to-calendar-button // atcb v1.14.6 //EN
CALSCALE:GREGORIAN
```

```
BEGIN:VTIMEZONE
TZID:/timezones-ical-library/20220824/America/New_York
LAST-MODIFIED:20220824T133813Z
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
```

```
BEGIN:VEVENT
UID:2022-08-30T19:29:38.618Z@add-to-calendar-button
DTSTAMP:20230214T091500Z
DTSTART;TZID=/timezones-ical-library/20220824/America/New_York:20230214T091500
DTEND;TZID=/timezones-ical-library/20220824/America/New_York:20230218T223000
SUMMARY:A sample event
DESCRIPTION:Just some descriptive text...
LOCATION:World Wide Web
STATUS:CONFIRMED
LAST-MODIFIED:20220830T192938Z
SEQUENCE:0
END:VEVENT
END:VCALENDAR
```

#### C. Get a specific offset

Use `tzlib_get_offset(tzName, isoDate, isoTime)` to get specific offset (relative to UTC), based on a provided date and time.

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 timezone at the 23rd of May in 2023 at exactly 15:45.

<br /><br />

---
Expand All @@ -84,4 +143,16 @@ Licensed under [Apache-2.0](LICENSE).

## ⚡ Changelog (without minor changes and fixes)

- v1.1 : get-offset function
- v1.0 : initial release

---

<br />

## 💜 Kudos go to

* 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 timezones for the web, ...
* as well as all the contributors at [the official tz repository](https://github.com/eggert/tz).
* 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).
* [Trevor Eyre](https://github.com/trevoreyre) for his smooth and beautiful [autocomplete script](https://github.com/trevoreyre/autocomplete).
76 changes: 38 additions & 38 deletions demo_assets/css/demopage.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,64 +66,52 @@ body.atcb-dark {
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/paytone-one-v18-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
}

/* nunito-300 - latin */
/* inter-300 - latin */
@font-face {
font-display: swap;
font-family: Nunito;
font-family: Inter;
font-style: normal;
font-weight: 300;
src: local(''),
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-300.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-300.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-300.ttf') format('truetype'), /* Safari, Android, iOS */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-300.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-300.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-300.ttf') format('truetype'), /* Safari, Android, iOS */
}

/* nunito-regular - latin */
/* inter-regular - latin */
@font-face {
font-display: swap;
font-family: Nunito;
font-family: Inter;
font-style: normal;
font-weight: 400;
src: local(''),
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-regular.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-regular.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
}

/* nunito-600 - latin */
/* inter-600 - latin */
@font-face {
font-display: swap;
font-family: Nunito;
font-family: Inter;
font-style: normal;
font-weight: 600;
src: local(''),
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-600.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-600.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-600.ttf') format('truetype'), /* Safari, Android, iOS */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-600.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-600.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-600.ttf') format('truetype'), /* Safari, Android, iOS */
}

/* nunito-800 - latin */
/* inter-800 - latin */
@font-face {
font-display: swap;
font-family: Nunito;
font-family: Inter;
font-style: normal;
font-weight: 800;
src: local(''),
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-800.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-800.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-800.ttf') format('truetype'), /* Safari, Android, iOS */
}

/* nunito-900 - latin */
@font-face {
font-display: swap;
font-family: Nunito;
font-style: normal;
font-weight: 900;
src: local(''),
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-900.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-900.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/nunito-v25-latin-900.ttf') format('truetype'), /* Safari, Android, iOS */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-800.woff2') format('woff2'), /* Super Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-800.woff') format('woff'), /* Modern Browsers */
url('https://tz.add-to-calendar-technology.com/demo_assets/fonts/inter-v12-latin-800.ttf') format('truetype'), /* Safari, Android, iOS */
}

/* fira-mono-regular - latin */
Expand Down Expand Up @@ -163,7 +151,7 @@ body {
background: var(--page-background);
box-sizing: border-box;
color: var(--text);
font-family: Nunito, Arial, sans-serif;
font-family: Inter, Arial, sans-serif;
font-size: 16px;
font-weight: 400;
height: 100%;
Expand Down Expand Up @@ -201,7 +189,7 @@ h1 {

h2 {
color: var(--text-subline);
font-size: 1.2em;
font-size: 1.1em;
font-weight: 800;
line-height: 1.5em;
max-width: 650px;
Expand All @@ -211,12 +199,25 @@ h2 {
}

h3 {
font-size: 1.2em;
line-height: 1.5em;
font-weight: 800;
text-align: left;
}

h4 {
font-weight: 800;
text-align: left;
}

p + h4,
pre + h4 {
margin-top: 60px;
}

@media only screen and (max-width: 800px) {
h3 {
h3,
h4 {
text-align: center;
}
}
Expand Down Expand Up @@ -463,8 +464,6 @@ body.atcb-dark .light-mode-switch div::after {
border: 1px solid var(--example-border);
border-radius: 6px;
display: none;
font-size: 0.8em;
text-align: left;
margin: 50px auto 0;
width: 100%;
max-width: 550px;
Expand Down Expand Up @@ -530,6 +529,7 @@ pre {
padding: 1em;
margin: .5em;
overflow: auto;
font-size: 0.8em;
}

:not(pre) > code,
Expand All @@ -546,7 +546,7 @@ pre {
border: 1px solid var(--example-border);
box-shadow: rgba(0 0 0 / 10%) 2px 5px 18px -1px, rgba(0 0 0 / 40%) 2px 2px 10px -3px;
border-radius: 8px;
font-family: Nunito, Arial, sans-serif;
font-family: Inter, Arial, sans-serif;
width: 280px;
padding: 12px 48px 12px 12px;
box-sizing: content-box;
Expand Down
Loading

0 comments on commit 73c43c8

Please sign in to comment.