PHP Timezone to iCalendar

1,147 views
Skip to first unread message

jamesdlow

unread,
Oct 18, 2010, 3:51:04 AM10/18/10
to SabreDAV Discussion
Hi Evert (and anybody else that might know the answer)

I saw your post here:
http://derickrethans.nl/storing-date-time-in-database.html

And wondered if you had any code or exmples for creating a VTIMEZONE
from a PHP timezone object.

I know there's the get transitions function:
http://www.php.net/manual/en/datetimezone.gettransitions.php

But it seems a pretty convoluted process to output this as a
VTIMEZONE, having to work out if the conditions still apply or the
country has stopped having day light savings, and specifying the RRULE
component.

Let me know if anybody has anything that could save me some time.
Thanks!
James

Evert Pot

unread,
Oct 18, 2010, 5:15:08 AM10/18/10
to sabredav...@googlegroups.com
On Mon, Oct 18, 2010 at 9:51 AM, jamesdlow <jame...@gmail.com> wrote:
Hi Evert (and anybody else that might know the answer)

I saw your post here:
http://derickrethans.nl/storing-date-time-in-database.html

And wondered if you had any code or exmples for creating a VTIMEZONE
from a PHP timezone object.

I don't, but getTransitions does seem like a good starting point.

For a number of custom implementations where I needed to construct my own VTIMEZONE, I actually just opted to only use UTC. It makes the implementation a lot simpler.

Evert

Ingo Ratsdorf

unread,
Oct 18, 2010, 5:18:54 AM10/18/10
to sabredav...@googlegroups.com
Hi James,

try iCalCreator @ http://www.kigkonsult.se/iCalcreator/index.php
maybe there's something in there.

Cheers,
Ingo

jamesdlow

unread,
Oct 18, 2010, 7:38:00 PM10/18/10
to SabreDAV Discussion
Hi Evert,

So if you specify returning all the times in UTC, you don't need to
worry about the Calendar VTIMEZONE at all?

James


On Oct 18, 5:15 pm, Evert Pot <evert...@gmail.com> wrote:

jamesdlow

unread,
Oct 18, 2010, 7:55:35 PM10/18/10
to SabreDAV Discussion
And related to that, should I always expect an iCalendar object to
return a UTC date. This seems to suggest it:
http://www.kanzaki.com/docs/ical/dtstamp.html

Evert Pot

unread,
Oct 19, 2010, 3:02:29 AM10/19/10
to sabredav...@googlegroups.com
> Hi Evert,

> So if you specify returning all the times in UTC, you don't need to
> worry about the Calendar VTIMEZONE at all?

No, you still need to specify it, like this:

BEGIN:VTIMEZONE
TZID:UTC
BEGIN:STANDARD
DTSTART:20071028T010000
TZOFFSETTO:+0000
TZOFFSETFROM:+0000
END:STANDARD
END:VTIMEZONE


On 2010-10-19, at 1:55 AM, jamesdlow wrote:

> And related to that, should I always expect an iCalendar object to
> return a UTC date. This seems to suggest it:
> http://www.kanzaki.com/docs/ical/dtstamp.html


No, it could be any timezone for DTSTART, DTEND, etc..

Ideally you retain all the timezones specified by the user, but when you're generating your own ics files, it might be helpful to just use UTC.

MIGHT, because it could still be annoying for DST changes. When you're dealing with recurring events, and you would stick to UTC, your events shift an hour after a DST change.
So it really depends on your needs.

It's not terribly difficult to generate suitable VTIMEZONE objects for other timezones though.

Evert

Reply all
Reply to author
Forward
0 new messages