FROM : Nick Zitzmann
DATE : Fri Feb 15 21:43:47 2008
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/>
DATE : Fri Feb 15 21:43:47 2008
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/>
| Related mails | Author | Date |
|---|---|---|
| norio | Feb 15, 09:13 | |
| Nick Zitzmann | Feb 15, 21:43 | |
| norio | Feb 16, 01:55 |






Cocoa mail archive

