NSCalendarDate saving and loading to get the same date-time
NSCalendarDate saving and loading to get the same date-time
- Subject: NSCalendarDate saving and loading to get the same date-time
- From: "Sarat Kongara" <email@hidden>
- Date: Mon, 9 Oct 2006 12:28:09 -0700
Hi,
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.
I know that the plist only saves date in NSDate, I tried this with
NSDate values and I get the same result. I also tried creating the
NSCalendarValues with [NSTimeZone localTimeZone] but I still get the
same result.
Interestingly if you save the value [NSDate
timeIntervalSinceReferenceDate] (which is NSTimeInterval == double)
and recreate the NSDate after load using [NSDate
dateWithTimeIntervalSinceRefenceDate:...] the date-time you get is not
the same meaning it is adjusted based on the timezone. I thought the
value should be same because you are giving an absolute elapsed time
since reference date.
I read all the earlier posts and documentation on NSCalendarDate and
NSDate but I didn't find anything related to this case. Any help is
greatly appreciated.
Regards
Sarat
_______________________________________________
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