Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Generalities about calendar components, iCal and date handling in js

Joseph Silvestre edited this page Nov 12, 2015 · 4 revisions

iCal is a widely supported standard for calendar description. It supports many use cases, but we will focus on Event and Alarm which are supported by cozy-calendar.

Event

Readable VEvent ical specification : http://www.kanzaki.com/docs/ical/vevent.html

Event objects can have variables behaviour, which covers 3 differents usecases.

1. Ponctual event

Use case : Schedule a first meeting oversea conf-call, on September the 15th 2014 at 10h00 America/New_York, and end at 12h00.

Date and time of the meeting is defined at creation. It will start at 14h00 UTC, which is 10h00 for New-Yorker, and 16h00 for Parisian.

The punctual events are defined by their UTC start and end date and time.

The simpler way to define start and end, is to save as utc datetime : start: "2014-09-15T14:00:00.000Z". Timezoned datetime can be used too, but are more complicated.

2. Recurring event

Use case : weekly team meeting, monday at 16h00, in Parisian office, with New-Yorker colleagues.

Every monday, summer and winter, at 4pm the team has it's weekly meeting. Which means, with DST (Daylight Saving Time) changes :

  • during the summer, event starts at 14h00 UTC, 10h00 America/New_York
  • during the winter, event starts at 13h00 UTC, 10h00 America/New_York
  • Monday, October the 27, 2014 : 13h00 UTC, 11h00 America/New_York (time change isn't the same week).

Recurring events are defined by their start and end date and time, in one chosen local time.

Start and end datetime must be defined as ambiguous time in the chosen timezone :

` start: "2014-10-20T16:00:00.000",

timezone: "Europe/Paris" `

3. AllDay event

Use case : the new year, January, the first.

The event is tight to the date only. It starts at the beginning of the day on each local time it is looked at.

AllDay event are defined by a date, without time indication.

Start and end date shows only dates : start: "2015-01-01" That means: my event will always be on 14h00, Paris time; whatever the user's timezone is. The reference is the event's timezone, not the user's one.

Alarm

Readable VAlarm iCal specifications: http://www.kanzaki.com/docs/ical/valarm.html

iCal defines VAlarm as reminders on VEvent or VTodo components. The TRIGGER field of VAlarm defines when the alarm should fire. It can be a fixed Datetime, or duration added to the start of the event, to create the trigger's datetime. Duration use a specific syntax as -PT10M (ie: 10 minutes before).

Date handling in javascript

Javascript provide the Date object to handle date and time. Date is not handy to work with timezones, because Date use the timezone of the environment it is running in : the browser (which take it from the OS), or LC_TIME locale variable in nodejs ; but doesn't provide a method to know which timezone it is using (getTimezoneOffset() isn't enough to know easily where are the change times), and doesn't allow to switch to another timezone.