In England, we use GMT for our timezone in winter and BST in summer. It's currently GMT but when I use this code to get the correct abbreviation it gives me BST:
let abbreviation = TimeZone.abbreviationDictionary.filter { $0.value == TimeZone.current.identifier }.keys.first
If I print out the TimeZone.current.identifier it gives me Europe/London. When I print out the TimeZone.abbreviationDictionary it gives me this:
["MST": "America/Phoenix", "ICT": "Asia/Bangkok", "NZST": "Pacific/Auckland", "CDT": "America/Chicago", "UTC": "UTC", "WEST": "Europe/Lisbon", "HKT": "Asia/Hong_Kong", "CST": "America/Chicago", "PKT": "Asia/Karachi", "BST": "Europe/London", "KST": "Asia/Seoul", "PET": "America/Lima", "SGT": "Asia/Singapore", "GST": "Asia/Dubai", "MDT": "America/Denver", "BRST": "America/Sao_Paulo", "ART": "America/Argentina/Buenos_Aires", "CET": "Europe/Paris", "AST": "America/Halifax", "NZDT": "Pacific/Auckland", "JST": "Asia/Tokyo", "CEST": "Europe/Paris", "BRT": "America/Sao_Paulo", "HST": "Pacific/Honolulu", "WIT": "Asia/Jakarta", "WET": "Europe/Lisbon", "AKST": "America/Juneau", "NST": "America/St_Johns", "EEST": "Europe/Athens", "CLT": "America/Santiago", "EST": "America/New_York", "PHT": "Asia/Manila", "GMT": "GMT", "CLST": "America/Santiago", "MSD": "Europe/Moscow", "TRT": "Europe/Istanbul", "PDT": "America/Los_Angeles", "COT": "America/Bogota", "PST": "America/Los_Angeles", "IRST": "Asia/Tehran", "MSK": "Europe/Moscow", "IST": "Asia/Kolkata", "NDT": "America/St_Johns", "WAT": "Africa/Lagos", "ADT": "America/Halifax", "BDT": "Asia/Dhaka", "AKDT": "America/Juneau", "CAT": "Africa/Harare", "EAT": "Africa/Addis_Ababa", "EET": "Europe/Athens", "EDT": "America/New_York"]
As you can see, there is a GMT in there but in order to get that, the TimeZone.current.identifier must return GMT and not Europe/London. Is this a bug? How can I fix this?
TimeZone.current.abbreviation(for: someDate)give me the correct abbreviation that adjusts to DST no matter where I am? - Tometoyou