Re: dateWithCalendarFormat: problem?
Re: dateWithCalendarFormat: problem?
- Subject: Re: dateWithCalendarFormat: problem?
- From: Nick Zitzmann <email@hidden>
- Date: Fri, 15 Feb 2008 13:43:47 -0700
On Feb 15, 2008 AD, at 1:13 AM, norio wrote:
If I typed "0" in the year part then typed 'tab', the DatePicker
displayed 0001/02/13.
Isn't it correct? I thought I would be 0000/02/13.
NSDatePicker is correct. There is no year 0 on the Gregorian calendar;
the people who designed the Julian calendar thousands of years ago
didn't have any concept of the number 0. Incidentally, there is no
year 0 in any other calendar type.
However if I pressed the button to convert it into NSCalendarDate
using dateWithCalendarFormat:timeZone:, the text field displayed
'-2007-01-27 01:00:00 +0900'.
NSLog showed the following.
2008-02-15 16:57:56.080 datepicker[1141:813] 2008-02-13 01:00:00 +0900
Would you tell me what I'm missing?
I think you somehow got NSDatePicker to go into the BC era, probably
by entering the year 0 beforehand. There's a subtle difference between
using NSCalendar/NSDate and NSCalendarDate to calculate date
components; NSCalendarDate assumes use of the Gregorian calendar
forever, whereas NSCalendar/NSDate starts using the Julian calendar
for dates prior to October 15, 1582 AD. That would explain the date
discrepancy.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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