Strange behavior of TimeZone abbreviation in reverse Geocoding...

I am trying to get local times for an event, and I keep getting different time depending on the type of device I am running on, either simulator, or real device. The code:

`do {
      let placemarks = try await CLGeocoder().reverseGeocodeLocation(location)
      if (placemarks.count) > 0 {
        let localPlacemark = placemarks.first!
        let timeZone = localPlacemark.timeZone!
        let tzString = timeZone.abbreviation()
        print("Time Zone for \(String(describing: localPlacemark.locality)) is \(tzString )")
        return localPlacemark.locality ?? "Unknown Locale"
      }
      else {
        print("Problem with the data received from geocoder")
      }
    } 

On an iPhone 14, the timeZone.abbreviation I get (for the same location) is "EST". But on an iPhone 13, I get "GMT-5", same on an iPhone 8. All three are running iOS 16.2. Has anyone ever seen this?

Also, since I am working with a full date during daylight savings time, on the 14 the time returned is correct (DST time), but "isDaylightSavingsTime" always returns false. This makes sense since the abbreviation is "EST" and not "EDT". However, the time returned is correct. On the iPhones 13 mini and 8, the time returned is Standard and not Daylight Savings. This is truly baffling. Any insights, suggestions or help are welcome! Thank you!!

Oh, and I should note that this only happens when the phone language is Spanish! If I revert to English, everything works as it should, even on iPhone 13 mini. Thank you for any help you can give me, this is holding up my development...thank you!

Time zone abbreviations are context sensitive. For example, EST is commonly used in Australia to mean Australian Eastern Standard Time [1]. So the fact that some devices get EST while others get GMT-5 is not a surprise.

If you plan to show time zone names to the user, check out the localizedName(_:locale:) method.

I should note that this only happens when the phone language is Spanish!

Which it seems like you’ve figured out. Although it’s the region (aka locale) not the language that matters here. I see different results for English (US) and English (UK).

As to any remaining weirdness, I suspect that Core Location is returning time zones that are different under the covers. I think you’ll be able to tell these apart using visible properties. For example:

let t1 = TimeZone(identifier: "America/Los_Angeles")!
let t2 = TimeZone(secondsFromGMT: -8 * 60 * 60)!

On an English (US) system I see this:

print(t1.abbreviation() ?? "-") // PST
print(t2.abbreviation() ?? "-") // GMT-8

And I can tell the difference like this:

print(t1.identifier) // America/Los_Angeles
print(t2.identifier) // GMT-0800

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] As if the eastern states in Aus could agree on a standard time! In reality, time zones in Australia are stupidly complex.

Strange behavior of TimeZone abbreviation in reverse Geocoding...
 
 
Q