我有时区:中欧夏季时间在OS (自动基于位置)。当在模拟器上运行我的代码时,我得到以下结果:
NSTimeZone *tz = [NSTimeZone localTimeZone]; // Gives me Local Time Zone (Europe/Warsaw (CEST) offset 7200 (Daylight))
NSString *tzString = [tz localizedName:NSTimeZoneNameStyleShortStandard
locale:[NSLocale currentLocale]]; // Gives me CET与EDT / EST一样,当我在系统->首选项中将当前时间设置为EDT时,适当的方法返回EST。
我是不是遗漏了什么?
发布于 2013-09-09 21:10:57
Standard in NSTimeZoneNameStyleShortStandard特别指时区的非DST名称。
如果您想要使用DST名称或不依赖于某个日期的DST状态,您可能必须使用-isDaylightSavingTimeForDate:来决定NSTimeZoneNameStyleShortStandard还是NSTimeZoneNameStyleShortDaylightSaving。
发布于 2015-02-23 12:35:54
苹果公司对时区缩写的使用发出警告。最好使用已知的偏移量使用+timeZoneForSecondsFromGMT:进行计算
使用属性-daylightSavingTime检查日照节省状态。
https://stackoverflow.com/questions/18697448
复制相似问题