NSDateFormatter for BST instead of GMT+1

情到浓时终转凉″ 提交于 2019-12-01 13:50:04
Nick T

Turns out there is a built in array of 48 time zone abbreviations (e.g. 'BST') in iOS.

NSDictionary *tzDict = [NSTimeZone abbreviationDictionary]; 

There is an array of 419 time zone names in this array (e.g. 'Europe/London'):

NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];

tzDict contains the abbreviations for daylight saving time for a subset of time zone names. So the algorithm would be to check if we are in DST, then see if tzDict has an entry, and subsitute that or if not, use

[NSTimeZone abbreviation];

Here are a few other topics on time zones in general.

Daylight saving time and time zone best practices

How can I map tz database names to city and country names?

C# british summer time (BST) timezone abbreviation

http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

GMT timezone conversion in objective c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!