Reputation: 330
My iOS swift application calls
TimeZone.current
when the application comes to the foreground. If I manually change the timezone from Settings->General->Date&Time, and then bring my application to the foreground, I get the correct timezone. But if my timezone setting was set to automatic, and then I turn off the automatic, and bring back my application to the foreground, the TimeZone.current
API does not reflect the new system timezone!
If I put the application to background and come back again to the foreground, this time it reflects the proper system timezone. Is this a bug in iOS SDK? Is there a workaround for this?
Upvotes: 1
Views: 282
Reputation: 9829
Try using NSTimeZone.local
, which is:
An object that tracks the current system time zone.
You can also use the NSTimeZone.system
property, but you'll need to manually call NSTimeZone.resetSystemTimeZone()
to clear and refresh the current cached system timezone value.
Upvotes: 1