Re: Re: NSCalendarDate saving and loading to get the same date-time
Re: Re: NSCalendarDate saving and loading to get the same date-time
- Subject: Re: Re: NSCalendarDate saving and loading to get the same date-time
- From: "Sarat Kongara" <email@hidden>
- Date: Mon, 9 Oct 2006 12:49:27 -0700
It *is* the exact same time, just expressed in another time zone
(i.e. when it's 2:30 in the US, it's about 11:30 in central Europe).
The time zone doesn't change the date, it changes how it is
displayed. So none of the things you observed is in any way surprising.
Yes, this I understand. But I was wondering why saving the value from
[date timeIntervalSinceReferenceDate] and recreating a new date using
[NSDate dateWithTimeIntervalSinceReferenceDate] returns different
date-time when different timezones are set during Save and Load.
Shouldn't the date-time be the same for all timezones when you are
calculating it from a absolute elapsed time from a reference date?
On 10/9/06, Uli Kusterer <email@hidden> wrote:
Am 09.10.2006 um 21:28 schrieb Sarat Kongara:
> I have a NSDictionary with a couple of NSCalendarDate objects as
> values, I save and load the dictionary to a plist file (using
> NSDictionary writeToFile... and NSDictionary
> dictionaryWithContentsOfURL... methods).
>
> Say I set the date-time to Oct 9th, 2006 10:30 AM (My timezone is set
> to New York in System Preferences) and save the dictionary. I change
> my timezone to San Francisco (In System Preferences) and load the
> dictionary the date-time is Oct 9th, 2006 7:30 AM.
>
> Is there a way to make sure the date-time is the same value (same
> mm-dd-yyyy hh:mm:ss ) after save and load even if the timezone is
> changed.
Save the time zone relative to which you specified your time and
restore it later, or query the OS for the time difference and save
that along with the date so you can adjust for it?
It *is* the exact same time, just expressed in another time zone
(i.e. when it's 2:30 in the US, it's about 11:30 in central Europe).
The time zone doesn't change the date, it changes how it is
displayed. So none of the things you observed is in any way surprising.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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