iPhone 日历和时区 (EventKit)
iPhone 上的时区处理对我来说似乎有点令人困惑。就向设备日历添加新的 EKEvent 而言,您似乎总是只设置本地时间的开始/结束时间,没有我们需要使用的时区或偏移量。这是真的吗?
我假设设备知道输入时的时区。当您查看设备的“设置/邮件”、“联系人”、“日历”并滚动到底部查看时区数据时,就会出现混乱。是否开启/关闭时区支持、设置时区等。
因此,如果我在加利福尼亚州并向设备添加事件,并且时区设置为“纽约”并且时区支持开启,那么什么时间EKEvent 真的会出现吗?
有没有人通过 EventKit 处理过 iOS 日历,并且有关于时区处理的经验教训?或者是简单直接,只需使用当地时间并输入事件,设备就会处理剩下的事情?
谢谢。
The time zone handling on the iPhone seems a little confusing to me. As far as adding a new EKEvent to the device calendar it looks like you always just set the start/end times in local time, there is no timezone or offset we need to work with. Is this true?
I assume the device knows the time zone at the time the entry is made. The confusion comes in when you look at the device's Settings/Mail, Contacts, Calendars and scroll to the bottom for the time zone data. Whether to have time zone support ON/OFF, a set time zone, etc.
So if I am in California and add an event to the device and the time zone is set to "New York" and time zone support is ON, what time will the EKEvent actually show in?
Has anyone dealt with the iOS calendar via EventKit and have lessons to learn regarding time zone handling? Or is it straight-forward, just use the local time and enter the event and the device will take care of the rest?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSDate 不没有时区,它们采用 UTC(据我所知)。如果您需要从/到某个时区进行转换,请使用 NSCalendar。我想 Mail 和朋友需要对来自外部源的日期进行明确的时区处理。
NSDate don't have a timezone, they're in UTC (AFAIK). If you need to convert from/to a certain timezone, use NSCalendar. I suppose Mail and friends need explicit timezone handling for dates coming from external sources.