10.8.2: NSDateFormatter returns incorrect object with -setTwoDigitStartDate set

Originator:mledford
Number:rdar://13030672 Date Originated:17-Jan-2013 12:20 AM
Status:Open Resolved:
Product:Mac OS X Product Version:10.8.2
Classification:Serious Bug Reproducible:Always
 
Summary:

I have found that NSDateFormatter returns incorrect objects with -setTwoDigitStartDate set and a particular dateFormat set as well.

Steps to Reproduce:

1) Alloc and init a new NSDateFormatter object.
2) Set the dateFormat to "MM/yy". That is a two digit month followed by a two digit year. (I have also tested with "M/yy" and the same problem occurs.)
3) Set the twoDigitStartDate to something. In my case I set it using the following:
    NSDate *twoDigitStartDate = [NSDate dateWithString:@"1930-12-31 23:59:59 +0000"];
    [dateFormatter setTwoDigitStartDate:twoDigitStartDate];
4) Have the formatter get the dateFromString: as the following shows:
    NSDate *dateObject = [dateFormatter dateFromString:@"04/13"];

Expected Results:

I would expect that the dateObject would be for April, 2013.

Actual Results:

The date object returned is for March, 2013.

Regression:

Works on 10.5, 10.6, 10.7.
Works if twoDigitStartDate is not set on 10.8.

Notes:

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!