NSDateFormatter default behaviour has changed in iOS 6

Originator:dave.addey
Number:rdar://12358210 Date Originated:24/9/2012
Status:Open Resolved:
Product:iOS SDK Product Version:6.0
Classification:Other Bug Reproducible:Always
 
Summary: NSDateFormatter's default date has changed to be 1/1/2000 in iOS 6, rather than 1/1/1970 in iOS 5 and earlier.

Steps to Reproduce:

Create an NSDateFormatter
Set a date format containing just a time formatting component
Create a new date from a string providing time information only
On iOS 6, the new date will use your supplied time, but the date will be 1/1/2000, rather than 1/1/1970

A sample project is attached. Run this project, and note the following code in viewDidLoad: in ViewController.m…

	NSDateFormatter * timeFormatter = [[NSDateFormatter alloc] init];
	[timeFormatter setDateFormat: @"HH:mmZ"];
	NSDate * date = [timeFormatter dateFromString:@"12:00 +0000"];
	NSLog(@"Date is %@", date);

on iOS 5.1, the output will be a date of 1970-01-01 12:00:00 +0000.
on iOS 6.0, the output will be a date of 2000-01-01 12:00:00 +0000.

Expected Results:
On iOS 5 and earlier, the date part of the new would be 1/1/1970, i.e. the Unix epoch; I would expect consistent behaviour on iOS 6.

Actual Results:
On iOS 6 and later, the date is 1/1/2000. Note that this is neither 1/1/2001 (the reference date) nor 1/1/1970 (the UNIX epoch and previous default date). This causes inconsistencies in date maths between dates and times created on iOS 6 and dates and times created on iOS 5 or earlier.
Note also that the new default date of 1/1/2000 appears even if apps are compiled against versions of the iOS SDK earlier than iOS 6. We are seeing this behaviour in an app that was linked against iOS 4.2.1, for example.

Regression:
iOS 5.

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!