Re: Back-to-front date formatting
Re: Back-to-front date formatting
- Subject: Re: Back-to-front date formatting
- From: Alexander Spohr <email@hidden>
- Date: Sat, 17 Jan 2004 18:36:00 +0100
jeremy,
the calendarFormat: part in init is to show NSCalendarDate how to parse
the string you throw at it. if the string does not contain what you
tell it, it will refuse to parse it. that's why you get nil.
if you want to get back a string formatted your way try using
- (NSString *)descriptionWithCalendarFormat:(NSString *)format
on your yearDate.
atze
Am 17.01.2004 um 12:53 schrieb Jeremy Dronfield:
On 16 Jan 2004, at 10:48 pm, Nicholas Riley wrote:
On Fri, Jan 16, 2004 at 10:16:53PM +0000, Jeremy Dronfield wrote:
The trouble is, -initWithString:calendarFormat: won't accept the year
at the beginning (it chokes and spits out a nil value). The same
happens if I try to extract the year with @"%Y". Does anyone know a
way
around this?
Perhaps this is a bug in Mac OS X 10.2.x? Date/time formatting was
quite
flaky in 10.2 and earlier, and was rewritten in 10.3, where your
example works fine:
NSCalendarDate alloc initWithString: '2004\nFriday 16 January'
calendarFormat: '%Y\n%A %e %b'
2004
Friday 16 Jan
I tried it with several other dates and had no problems.
If you are using 10.3, make sure the string actually contains what you
think it does...
I am in fact using 10.3. Having played around some more, it seems that
-initWithString:calendarFormat: will only work if the string is
already formatted to match calendarFormat. If any elements are missing
from the string, or are in a different order, the result is a nil
string. Therefore, the only purpose of the method is to add textual
features such as commas, carriage returns etc.
-Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.