Time zone problem with CoreData
Time zone problem with CoreData
- Subject: Time zone problem with CoreData
- From: Kevin Hoctor <email@hidden>
- Date: Mon, 11 Feb 2008 19:15:35 -0600
I'm running into problems with storing dates in CoreData SQLite
databases. I've tried to use GMT dates without times to keep the
queries clean like this:
- (void)setDate:(NSDate *)value
{
// convert to calendar date so we can strip time and set GMT timezone
NSCalendarDate *c = [NSCalendarDate
dateWithTimeIntervalSinceReferenceDate:[value
timeIntervalSinceReferenceDate]];
[self willChangeValueForKey: @"date"];
[self setPrimitiveValue:[NSCalendarDate dateWithYear:[c
yearOfCommonEra] month:[c monthOfYear] day:[c dayOfMonth] hour:0
minute:0 second:0 timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]
forKey: @"date"];
[self didChangeValueForKey: @"date"];
}
The problem is that when the dates are retrieved, they are coming in
with a local time zone causing the date to show as yesterday. It
doesn't matter that I'm displaying the dates with a GMT time zone, the
actual value from (NSDate *)date has the time zone.
I don't even want the time. What is the correct way to keep time zones
out of the equation with CoreData?
Peace,
Kevin Hoctor
email@hidden
No Thirst Software LLC
http://nothirst.com
http://kevinhoctor.blogspot.com
_______________________________________________
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