假设iOS 7中的NSTimeZone timeZoneWithName:
接受带有非特殊区域(如America/New_York
)和special area(如Etc/UTC
)的时区ID,但是NSTimeZone name
绝不会返回特殊区域(而是会返回例如Europe/London
)?
谁可以确认?
最佳答案
我认为这不是一个安全的假设。在OS X上,在我的时区和语言环境(美国英语,UTC-6)上,我可以运行以下代码:
NSTimeZone *utc = [NSTimeZone timeZoneWithName:@"Etc/UTC"];
NSTimeZone *london = [NSTimeZone timeZoneWithName:@"Europe/London"];
NSLog(@"utc name = %@", [utc name]);
NSLog(@"london name = %@", [london name]);
给出以下输出:utc名称= Etc / UTC
伦敦名称=欧洲/伦敦
因此,如果在实例化时区时为其指定了特殊区域,则该时区将继续使用其名称。作为复杂的附加层,使用
+timeZoneWithAbbreviation:
还将获得不同的名称,例如: NSTimeZone *utc2 = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
NSLog(@"utc2 name = %@", [utc2 name]);
utc2名称= GMT
关于ios - NSTimeZone和特殊时区等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23879709/