Re: dateWithCalendarFormat: problem?
Re: dateWithCalendarFormat: problem?
- Subject: Re: dateWithCalendarFormat: problem?
- From: norio <email@hidden>
- Date: Sat, 16 Feb 2008 09:55:07 +0900
Nick, Thank you.
I got the reason why it comes, thanks to you, but I'm still worried
about this. Because I happened to find the problem when I first typed
'0' then 'tab' by mistake and reentered correct number in the year
component, I think someone else can do the same thing. Since my code
needs to get 'year' from NSDate, wrong value 'year' can be returned.
I'll set its minimum date to prevent users from typing such a wrong
number in year component.
Thank you for letting me notice the way.
Norio Ota
On 2008/02/16, at 5:43, Nick Zitzmann wrote:
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