dateWithNaturalLanguageString problems
dateWithNaturalLanguageString problems
- Subject: dateWithNaturalLanguageString problems
- From: Olivier Scherler <email@hidden>
- Date: Sat, 2 Apr 2005 13:01:44 +0200
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?
The second problem is that if I provide an unreasonable value to
dateWithNaturalLanguageString, like “1111111111”, the method takes it as the
year and locks-up for hald a minute before returning 5744332-02-01 12:00:00
+0100. I have no problem with the strange date but the time it takes to return
it is unnacceptable.
Unfortunately, I see no way of checking the validity of the given string before
calling dateWithNaturalLanguageString, unless I reimplement the whole method
myself. And even in this case, it doesn’t solve the first problem.
Any input would be greately appreciated before I report these two issuse as bugs
to Apple.
Olivier
∞ Unicode Ribbon Campaign — No ASCII, anywhere ∞
∞ <http://ithink.ch/unicode> ∞
:: Olivier Scherler :: Neuchâtel - Switzerland :: http://ithink.ch/blog/ ::
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden