Calling a list of time zones

For my application, I am importing a calendar event from a Google calendar. The only problem I encountered is the list of time zones. I get the time zone as the result from Google Calendar xml, which I have to check with the list of time zones and add the time accordingly ... so where can I get this standard list of time zones from .. or some other alternative to achieve the same.

+1
source share
3 answers

If you use Java, use Joda Time - the time zone identifier specified in Google Calendar will be what Joda Time understands. The standard TimeZone class may well understand this, but I think Joda is more likely.

Assuming you see all VTIMEZONE content that comes with the event, you can ignore the details - just use the identifier.

Unfortunately, there are some time zone identifiers that have changed over time - I can’t recall any examples from hand to hand, but you may need to make some translations if you are given the β€œold” names.

If you are using .NET, you really need to use .NET 3.5 and the TimeZoneInfo class. Unfortunately, this uses Windows names instead of Olson identifiers, but there is a translation list somewhere (I can dig it out if you want).

If you are not using any of these platforms, you basically need to find a library that supports the Olson Zoneinfo names . (There are useful links below in this Wikipedia article.)

I would definitely try to find a library that can provide you relevant information based on the identifier, rather than using the rules listed in the calendar entry. Time zones change over time, and the zoneinfo database contains historical and future information, but this cannot be easily encoded into calendar entries.

+2
source

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

+1
source

Check out these features.

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

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

There is no library for accessing time zone data files in Erlang / OTP, and as far as I know, it does not have a third-part library. Thus, your options for you turn available time zone databases into something that you can use from Erlang, or just to know a few of them.

You know, if you do not want to run a project to read time zone data in Erlang. :-)

+1
source

Source: https://habr.com/ru/post/1345665/


All Articles