Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timzones-ical-library

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timzones-ical-library

Easy direct access to the most recent official timezone information for iCalendar files

  • 1.1.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

Add to Calendar TimeZone iCal Library


Add to Calendar TimeZones iCal Library

The tool to convert the IANA (formerly Olson) timezone database files into VTIMEZONE blocks, compatible with the iCalendar specification (RFC2445).

It is based on the awesome tool by Damon Chaplin (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). It is built to be used standalone or as JavaScript module, hosted as npm package.





📦 Installation / Setup

0. Update it (not required)

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 IANA timezone database you want to use (e.g. sudo sh update-tzdata.sh 2022c).


1. Load it

A. VanillaJS

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:

  • require the package (commonJS) or ...
  • import the module (ES) via import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'timezones-ical-library';.

2. Use it

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.





🙌 Contributing

Anyone is welcome to contribute, but mind the guidelines:


Licensed under Apache-2.0.


⚡ Changelog (without minor changes and fixes)

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


💜 Kudos go to

Keywords

FAQs

Package last updated on 30 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc