views:

375

answers:

3

For my application, I'm importing the calendar event from google calendar. The only problem which I'm facing is Time zone list. I'm getting the timezone as output from google calendar xml, which I have to check with time zone list and add time accordingly... so from where I can get this standard time zone list.. or some other alternative to achieve the same.

+2  A: 

If you're using Java, use Joda Time - the time zone ID given by Google Calendar will be one the Joda Time understands. The standard TimeZone class may well understand it too, but I think Joda is more likely to.

Assuming you're seeing all the VTIMEZONE stuff that goes along with the event, you can ignore the details - just use the ID.

Unfortunately there are some time zone IDs which have changed over time - I can't remember any examples off-hand, but you may need to do some translations if you're provided with the "old" names.

If you're using .NET, you really need to be using .NET 3.5 and the TimeZoneInfo class. Unfortunately that uses Windows names instead of Olson IDs, but there's a translation list available somewhere (I can dig it out if you want).

If you're not using either of these platforms, you basically need to find a library which supports Olson Zoneinfo names. (That wikipedia article has some helpful links at the bottom.)

I would definitely try to find a library which will be able to give you the relevant information based on an ID, rather than using the rules given back in the calendar entry. Time zones change over time, and the zoneinfo database contains historical and future information, but that can't be easily encoded in the calendar entry.

Jon Skeet
i m trying to achieve this thing ine erlang..
Abhimanyu
It would have been helpful to say so in the question. Okay, well I know nothing about Erlang - but there must be some decent date/time libraries for it, and I would imagine they would understand Olson IDs.
Jon Skeet
I don't blame you Jon, your shot covered 90% or better, but Erlang comes in at about 100-1 ... Charlie Martin cashes big long shot ticket. :)
JP Alioto
+1  A: 

There are some good articles about working with Erlang date/time libraries here: http://www.trapexit.org/Category:DateTimeRecipes
Hope it helps.

GK
+1  A: 

Check out these function

calendar:datetime_to_gregorian_seconds({Date, Time})
calendar:gregorian_seconds_to_datetime(Seconds) -> {Date, Time}

Converting to "gregorian seconds" and correcting the timezone-offset and converting back to date form is half the solution.

There is no library to access timezone datafiles in Erlang/OTP, and as far as I know there is no third part library to get at it either. So your options are to yourself convert the available timezone databases to something usable from Erlang, or to settle for just knowing a few of them.

You know, unless you want to start a project to read timezone data in Erlang. :-)

Christian