Skip navigation.
 
mlRe: dateWithNaturalLanguageString problems
FROM : Ben Dougall
DATE : Mon Apr 04 01:35:59 2005

On Saturday, April 2, 2005, at 12:01  pm, Olivier Scherler wrote:

> I am using [NSCalendarDate dateWithNaturalLanguageString: string] in my
> application. It is very convenient because it allows the user to enter
> a date
> with a minimum of fuss, e.g. (today is 4/2/2005)
>
> typing  1    leads to  4/1/2005,
> typing  3/1  leads to  3/1/2005,
> typing  42  leads to  4/2/1942.
>
> However I am experiencing two problems with this method.
>
> The first one is that it does not take into account the system
> settings for date
> ordering. My International settings are set for Swiss French, which
> explicitely
> states that a date is displayed as “Day Month Year” (i.e.
> NSDateTimeOrdering of
> “DMYH”). dateWithNaturalLanguageString however keeps interpreting
> strings as
> “Month Day Year” (i.e. NSDateTimeOrdering of “MDYH”). The developer
> documentation mentions that
>

>> In parsing the string, this method uses the date and time preferences
>> stored in the user’s defaults database.

>
> Therefore I suspect that it is a bug in the system, that
> NSDateTimeOrdering is
> not set with respect to the International preference pane as it
> should. Am I the
> only one experiencing this problem? Is there a known workaround that
> doesn’t
> involve hard coding the date ordering in the application?


i've come across and asked about that. see
<http://www.cocoabuilder.com/archive/message/cocoa/2005/2/23/128884>. i
concluded that i needed to get the text format string of one of the
standard date formats (which are based on the user's system settings)
and manipulate that to make a new date format as the user would want to
see it.

basically it seems that NSDateTimeOrdering is useless.

Related mailsAuthorDate
mldateWithNaturalLanguageString problems Olivier Scherler Apr 2, 13:01
mlRe: dateWithNaturalLanguageString problems Ben Dougall Apr 4, 01:35