NSCalendar and NSDates prior to October 15, 1582
NSCalendar and NSDates prior to October 15, 1582
- Subject: NSCalendar and NSDates prior to October 15, 1582
- From: Steve Mykytyn <email@hidden>
- Date: Fri, 30 Jan 2015 09:32:40 -0800
The documentation for the Date and Time Programming Guide for iOS does not
seem to be telling the truth, or perhaps I'm doing something wrong.
From
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtHist.html
"The Julian to Gregorian Transition
NSCalendar models the transition from the Julian to Gregorian calendar in
October 1582. During this transition, 10 days were skipped. This means that
October 15, 1582 follows October 4, 1582. All of the provided methods for
calendrical calculations take this into account, but you may need to
account for it when you are creating dates from components. Dates created
in the gap are pushed forward by 10 days. For example October 8, 1582 is
stored as October 18, 1582."
This code:
NSCalendar *calendar = [NSCalendar
calendarWithIdentifier:NSCalendarIdentifierGregorian];
DDLog(@"calendar = %@
----------------------------------------",calendar.calendarIdentifier);
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:1582];
[components setMonth:10];
[components setDay:10];
NSDate *date = [calendar dateFromComponents:components];
DDLog(@"components2 = %@",components);
DDLog(@"date = %@",date);
yields this result:
DateLimit: calendar = gregorian ----------------------------------------
DateLimit: components2 = <NSDateComponents: 0x7be5b610>
Calendar Year: 1582
Month: 10
Day: 10
DateLimit: date = 1582-10-10 07:52:58 +0000
Every other calculation I've tried seems to indicate that NSCalendar
provides a proleptic Gregorian calendar - i.e. it does not adjust for the
October 15 following October 4 transition.
_______________________________________________
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