Re: NSDateFormatter giving different results in different programs
Re: NSDateFormatter giving different results in different programs
- Subject: Re: NSDateFormatter giving different results in different programs
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 14 Apr 2008 11:09:44 -0600
On Apr 13, 2008, at 11:21 PM, Derrick Bass wrote:
In one program that links to this framework, the date is getting
parsed correctly. But in another, the very same string is coming
back as "1969-12-31 16:00:00 -0800"! Using -
[getObjectValue:forString:range:error:] gives the same results....
no error.
What could be causing the different behaviors and how do I get the
string to parse no matter what?
There are two styles of NSDateFormatter: The pre-Tiger style (10.0)
and the Tiger & later style (10.4). The latter supports non-Gregorian
calendars and automatically fetching properly localized date
formatters, but when parsing strings into dates, they require the
format to be extremely strict or they don't work. The former only
supports the Gregorian calendar, and the methods of getting properly
localized date formats have been deprecated, but they are much more
flexible in the kind of input they take.
So make sure both formatters are of the 10.0 style.
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