question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting UTC timestamps of iCal with Timezone

See original GitHub issue

I have some iCal-data with a timezone-definition (Europe/Copenhagen; CET/CEST), but I can’t get the dates specified in this timezone out in UTC.

Roughly:

BEGIN:VTIMEZONE
TZID:Europe/Copenhagen
...
END:VTIMEZONE
BEGIN:VEVENT
...
DTSTART;TZID=Europe/Copenhagen:20131120T113000
...
END:VEVENT

When I parse it, I it seem to believe the UTC-offset is 0, no matter how I poke at it.

event = new ICAL.Event(
    ICAL.Component(ICAL.Parse(DATA)[1]).getFirstSubcomponent('vevent')
);

event.startDate.toJSDate();
// In computer localtime.

event.startDate.utcOffset();
// 0 - should be 1 or 2 hours, depending on summertime.

console.log(event.startDate);
{ wrappedJSObject: [Circular],
  _time: 
   { year: 2013,
     month: 11,
     day: 20,
     hour: 11,
     minute: 30,
     second: 0,
     isDate: false },
  _pendingNormalization: false,
  timezone: 'Europe/Copenhagen',
  zone: 
   { wrappedJSObject: [Circular],
     expandedUntilYear: 0,
     changes: [],
     tzid: 'floating' } }

Can anyone give some pointers as to what I’m doing wrong?

Also: How do I generate startTime and endTime with timezone-definitions? ICAL.Time.fromData({...}, iCalTz) doesn’t add the timezone-definition…

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
msiebuhrcommented, Nov 28, 2013

It turns out the parser doesn’t hook up the timestamps with TZID:<name> to the corresponding VTIMEZONE. If I monkey-patch ex. the startDate w. startDate.zone = new ICAL.Timezone(comp.getFirstSubcomponent('vtimezone')); it works fine.

3reactions
kennethmac2000commented, Nov 29, 2016

Anyone had any further thoughts on this? It’s still the case that when you make a toJSDate() call, the TZID value in a VEVENT is ignored. This makes that call currently fairly useless without some hackery.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting UTC timestamps of iCal with Timezone #102 - GitHub
I have some iCal-data with a timezone-definition ( Europe/Copenhagen ; CET / CEST ), but I can't get the dates specified in this...
Read more >
Create ical with timezone using utc offset instead of time zone ...
in my database i'm storing datetimes in UTC with additional column timezone offset as time zone instead of timezone name ...
Read more >
iCalendar spec: 4.3.5 Date-Time - The Web KANZAKI
In most cases, a fixed time is desired. To properly communicate a fixed time in a property value, either UTC time or local...
Read more >
ZDateHelper - iCalendar.org
... "UTC") : integer. Return current Unix timestamp in local timezone ... $tzid = "UTC"). Date math: add or substract from current date...
Read more >
Org-Mode iCalendar Export with Explicit Time Zones | Tero Hasu
It is existing Org behavior to translate non-"UTC" TIMEZONE specifying date-time timestamps into RFC 5545 DATE-TIME values in the “DATE WITH ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found