Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
- Subject: Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
- From: Deborah Goldsmith <email@hidden>
- Date: Fri, 14 Jan 2011 13:34:46 -0800
Did you write a bug for this? What is the bug number?
Thanks,
Deborah Goldsmith
Apple Inc.
On Jan 10, 2011, at 10:12 AM, Steve Mykytyn wrote:
> UIDatePicker (4.2.1) shows differing dates for the modes
>
> UIDatePickerDate (correct), and
>
> UIDatePickerDateAndTime (incorrect)
>
> when the timezone you assign to the UIDatePicker is
>
> - more than 12 hours ahead (east) of the systemTimeZone of the iPhone.
>
> For example,
>
> device system time zone = America/Los Angeles = GMT - 8
>
> Honolulu date: Dec 7, 1941 7:48am
>
> Tokyo date: Dec 8, 1941 3:18am
>
> UIDatePicker will show the Tokyo date for mode
>
> UIDatePickerDate (correct): Dec 8, 1941
>
> UIDatePickerDateAndTime: Dec 7, 1941
>
> In fact, UIDatePicker will show incorrect dates in this case for any time zone east of GMT + 4 (always one day before correct day)
>
>
> A work-around in viewDidLoad is:
>
> self.datePicker.datePickerMode = UIDatePickerModeDateAndTime;
>
> self.datePicker.minuteInterval = 1;
>
> self.datePicker.timeZone = timeZone;
>
> [NSTimeZone setDefaultTimeZone:timeZone]; // *** add this line to force date picker to show correct date in all modes
>
> [self.datePicker setDate:tzDate animated:YES];
>
> and in viewWillDisappear add:
>
> [NSTimeZone resetSystemTimeZone];
>
> [NSTimeZone setDefaultTimeZone:[NSTimeZone systemTimeZone]];
>
> Not super happy about the work-around, but it should be fairly robust even if this bug is fixed in future.
>
> If anyone can shed some light on this behavior, please advise. No amount of fooling around with calendars, locales, etc. fixed this until i reset the default zone.
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden