Re: Date / time localisation
Re: Date / time localisation
- Subject: Re: Date / time localisation
- From: "Sean McBride" <email@hidden>
- Date: Mon, 2 May 2005 11:16:09 -0400
- Organization: Rogue Research
On 2005-04-17 23:08, Adam Holt said:
>I'm reading in an XML file from a web server. The XML defines a number of
>events and each one is timestamped by the server.
>
>I want my cocoa app to read the timestamps but display them in the app as
>local time for the user (i.e. offset according to the local system timezone
>of their Mac).
>
>The XML file is generated by my own Java servlet so I can tweak the format
>to make it more compatible with the Cocoa classes as necessary.
I would suggest using the format "%Y-%m-%d %H:%M:%S %z"
>I'd appreciate a couple of pointers on this subject as I've looked at a UTC
>related thread on cocoa-dev back in June '04 as well as the cocoa date /
>time overview at
>http://developer.apple.com/documentation/Cocoa/Conceptual/DatesAndTimes/inde
>x.html but I don't have a clear idea as to how to approach this yet.
You can use NSCalendarDate's dateWithString:calendarFormat: to create the
NSCalendarDate from your XML data, then use:
NSString* sdf = [[NSUserDefaults standardUserDefaults] stringForKey:
NSDateFormatString];
NSDictionary* locale = [[NSUserDefaults standardUserDefaults]
dictionaryRepresentation];
[aDate descriptionWithCalendarFormat:sdf locale:locale];
Sadly, passing nil's to descriptionWithCalendarFormat does not get you
localised date strings.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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