Bug in iOS 18 with NSTimeZone and DatePicker

iOS 18 broke some functionality in my Objective-C app with regard to using the DatePicker.

The key lines are as follows:

datePicker.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:timezoneOffset];
datePicker.date = [NSDate date];

When timezoneOffset is -29380, the value for San Francisco, the Date Picker is a whole MONTH off. It shows November instead of December.

But when it is -29359, the value for Seattle, which is in the same time zone (PST), it shows the correct month. In fact, even towns surrounding San Francisco usually return the correct value. Some other cities in other time zones also cause the Date Picker to be a month off.

Which date picker are you talking about here?

Your tagged your thread with AppKit, which suggests NSDatePicker. But then you talk about iOS, and NSDatePicker isn’t available on that platform. Are you using UIDatePicker? Or SwiftUI?

Share and Enjoy

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

I’m wondering about the purpose of those weird offset values, since they represent the offset in mean solar time at the longitude of those cities rather than official time zones. It’s not inconceivable that some bug exists somewhere in handling nonstandard time zone offsets like that.

It’s better to reply as a reply. See Quinn’s Top Ten DevForums Tips for this and other titbits.

UIDatePicker

OK. I retagged your thread accordingly.

it wasn't an issue before iOS18.

Unfortunately that doesn’t help us understand the root cause of this; time zones are complex enough that there’s plenty of scope for undefined behaviour.

Can you elaborate on what you mean by this?

But when it is -29359, the value for Seattle, which is in the same time zone (PST)

Seattle and SF are in the same time zone, so why would they have different timezoneOffset values?

Also, what does -29359 even mean? It translates to -8.1527… hours, which isn’t a meaningful time zone offset.

Share and Enjoy

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

Bug in iOS 18 with NSTimeZone and DatePicker
 
 
Q