NSCalendar does not correctly use local timezone when creating date components

Originator:scelis
Number:rdar://9636532 Date Originated:19-Jun-2011 08:16 AM
Status:Open Resolved:
Product:iPhone SDK Product Version:4.3.3
Classification:Other Bug Reproducible:Always
 
Summary:

When the system timezone changes, any NSCalendars previously created with [NSTimeZone localTimeZone] will use the old timezone information instead of the new timezone information when constructing NSDateComponents from NSDates.


Steps to Reproduce:

1. Launch your application in timezone A.
2. Create an NSCalendar.
3. Assign [NSTimeZone localTimeZone] to that calendar.
4. Call components:fromDate: on that calendar. Notice that the information is correct.
5. Background the app.
6. Change the system timezone to timezone B.
7. Bring the app to the foreground.
8. Call components:fromDate: on the calendar created in step (2). Notice that the components are created using timezone A instead of timezone B, even though the [NSTimeZone localTimeZone] instance indeed references the new timezone.


Expected Results:

Because the NSCalendar is using [NSTimeZone localTimeZone], I expect the calendar to automatically use the new timezone when the device timezone changes. Instead, it appears to use the old timezone, thus creating incorrect NSDateComponents from dates. Calling [NSTimeZone resetSystemTimeZone] does not help. NSLogging the calendar timezone after changing the system timezone shows that the localTimeZone has updated correctly. However, components:fromDate: does not work as expected.


Actual Results:

The calendar uses the old timezone information for subsequent calls to components:fromDate:



Regression:

Unknown.


Notes:

Please see the attached sample project that demonstrates this issue.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!