While writing some unit tests on a Julian Day calculator, I found that dates prior to 2nd December 1847 were being initialised incorrectly by NSDate. They appear to have 75 seconds added on. I haven't been able to find anything pointing to that date (which is well after the Gregorian calendar cutoff). Is it a bug or is there a historic calendar adjustment that I've not come across?
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *dateComps = [NSDateComponents new];
dateComps.year = 1847;
dateComps.month = 12;
dateComps.day = 1;
NSDate *d1 = [cal dateFromComponents:dateComps];
NSLog(@"d1 = %@", d1);
dateComps = [NSDateComponents new];
dateComps.year = 1847;
dateComps.month = 12;
dateComps.day = 2;
NSDate *d2 = [cal dateFromComponents:dateComps];
NSLog(@"d2 = %@", d2);
}
return 0;
}
Output:
d1 = 1847-12-01 00:01:15 +0000
d2 = 1847-12-02 00:00:00 +0000