时区列表问题
对于我的应用程序,我从谷歌日历导入日历事件。 我面临的唯一问题是时区列表。 我从 google calendar xml 获取时区作为输出,我必须检查时区列表并相应地添加时间...所以从哪里我可以获得这个标准时区列表..或其他一些替代方案来实现相同的目的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 Java,请使用 Joda Time - Google 日历给出的时区 ID 将是乔达时代理解的一个。 标准的 TimeZone 类也可能很好地理解它,但我认为 Joda 更有可能理解它。
假设您看到了与事件相关的所有 VTIMEZONE 内容,您可以忽略详细信息 - 只需使用 ID。
不幸的是,有些时区 ID 随着时间的推移而发生了变化 - 我记不起任何即时示例,但如果为您提供了“旧”名称,您可能需要进行一些翻译。
如果您使用 .NET,则确实需要使用 .NET 3.5 和
TimeZoneInfo
类。 不幸的是,它使用 Windows 名称而不是 Olson ID,但在某处有一个可用的翻译列表(如果您愿意,我可以将其挖掘出来)。如果您不使用这些平台中的任何一个,则基本上需要找到一个支持 Olson Zoneinfo 名称< /a>. (那篇维基百科文章的底部有一些有用的链接。)
我肯定会尝试找到一个能够根据 ID 为您提供相关信息的库,而不是使用日历条目中给出的规则。 时区会随着时间的推移而变化,并且 zoneinfo 数据库包含历史和未来信息,但无法轻松地在日历条目中进行编码。
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.
这里有一些关于使用 Erlang 日期/时间库的好文章:
http://www.trapexit.org/Category:DateTimeRecipes
希望能帮助到你。
There are some good articles about working with Erlang date/time libraries here:
http://www.trapexit.org/Category:DateTimeRecipes
Hope it helps.
查看这些函数
转换为“公历秒”并更正时区偏移并转换回日期形式是解决方案的一半。
Erlang/OTP 中没有可以访问时区数据文件的库,据我所知也没有第三方库可以访问它。 因此,您的选择是自己将可用的时区数据库转换为 Erlang 中可用的数据库,或者满足于只了解其中的一些数据库。
你知道,除非你想启动一个项目来读取 Erlang 中的时区数据。 :-)
Check out these function
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. :-)