ios - 夏令时 UIDatePicker 问题

标签 ios objective-c swift date

我遇到的问题:

In the case of the United States where a one-hour shift occurs at 02:00 local time, in spring the clock jumps forward from the last moment of 01:59 standard time to 03:00 DST and that day has 23 hours, whereas in autumn the clock jumps backward from the last moment of 01:59 DST to 01:00 standard time, repeating that hour, and that day has 25 hours.[37] A digital display of local time does not read 02:00 exactly at the shift to summer time, but instead jumps from 01:59:59.9 forward to 03:00:00.0.

并且 UIDatePicker 没有机会在 DST 发生时设置 02:00:00 时间。如何在 UIDatePicker 中修复能够选择那个时间?

最佳答案

NSTimeZone是定义时区对象行为的抽象类。时区对象代表地缘政治区域。夏令时也由该类管理。它可以通过以下方式之一完成:

  • 系统时区: 系统当前使用的时区。如果无法确定当前时区,则返回 GMT 时区。

  • 默认时区: 当前应用程序的默认时区。如果未设置默认时区,则此方法调用 systemTimeZone 并返回系统时区。

  • 本地时区: 将所有消息转发到当前应用程序的默认时区的对象。本地时区始终代表默认时区的当前状态。

使用 localTimeZone 类方法,您可以获得一个相对时区对象,该对象将自身解码为它所在的任何计算机上的默认时区。

关于ios - 夏令时 UIDatePicker 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34416090/

相关文章:

ios - IOS模拟器中的硬件加速框架是否反射(reflect)了它在真正的iphone上的作用?

iOS : Customizing TableViewCell - Initializing Custom Cell

swift - 有没有办法通过使用包含类名的变量来快速初始化类?

ios - 从另一个 UITableViewCell 类隐藏自定义 UITableViewCell

swift - CK订阅错误iOS10

ios - Parse - 如何在更多数据添加到解析数据库时更新 tableView?

ios - 是什么导致了 <Error> : CGContextSetBaseCTM: invalid context 0x0 when implementing loadView?

ios - 使用 Alamofire 进行 session 管理

具有目标操作的单元格上的 iOS UIButton,单元格未在 (id)sender 中更新

ios - JASidepanels 不显示导航按钮