Re: Need localization-proof method of transporting dates.
Re: Need localization-proof method of transporting dates.
- Subject: Re: Need localization-proof method of transporting dates.
- From: Michael Ash <email@hidden>
- Date: Wed, 8 Apr 2009 00:31:53 -0400
On Wed, Apr 8, 2009 at 12:11 AM, Graham Cox <email@hidden> wrote:
> Well, the date itself is stored in the archive using standard archiving. I'm
> not sure how it writes itself - so should I be worried? I thought I could
> rely on archiving/dearchiving accurately giving me back whatever I stored
> though in this case there could be a tiny change.
>
> The date comes from a NSDatePicker control, which is set to have 1 minute
> resolution (which is still more than I need, 1 day res would be fine,
> haven't looked into whether there's a way to lose the time part in the
> control). I can certainly pre-process the received date to truncate it to a
> whole minute or even a whole day. I should probably do this to make sure.
I got curious and experimented. Archiving (as in NSCoder) appears to
work fine, but if you send an NSDate through an XML plist, it loses
its fractional seconds! (rdar://6768646) So if you're using plist
serialization, you may well not get the same date out that you put in.
However, since it sounds like you'll always get a whole number of
seconds (a multiple of 60, for that matter) then you should be fine.
Explicitly rounding on your side of things certainly wouldn't hurt
either.
Mike
_______________________________________________
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