• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone


  • Subject: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
  • From: Steve Mykytyn <email@hidden>
  • Date: Mon, 10 Jan 2011 10:12:15 -0800

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

  • Follow-Ups:
    • Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
      • From: Deborah Goldsmith <email@hidden>
  • Prev by Date: Re: Initializing a view controller...
  • Next by Date: Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
  • Previous by thread: Re: Initializing a view controller...
  • Next by thread: Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone
  • Index(es):
    • Date
    • Thread