Time creation and storage
Time creation and storage
- Subject: Time creation and storage
- From: Robert Walker <email@hidden>
- Date: Thu, 20 Apr 2006 15:04:41 -0400
I have bumped into an issue with creating and storing time using NSDate.
I have the following structure in my Core Data model:
The Scenario:
-----------------------------------------------------
LogSheet <------->> Event
There is one LogSheet per day. LogSheet has a date field.
Each LogSheet can have multiple Events with a start and end time for
each event.
-----------------------------------------------------
The Problem:
------------------------------------------------------
I'm using the following code to create the start and end times for
Event:
[anEvent setValue:[NSCalendarDate dateWithString:@"0800"
calendarFormat:@"%H%M"] forKey:@"startTime"];
I find it strange that the above example produces this result:
2006-01-01 08:00
Instead of:
1970-01-01 08:00 <-------- 08:00 of the UNIX reference date
Normally I wouldn't really care about this since I'm only interested
in the time. However, this application is a Cocoa "front end" to a
WebObjects Web Service application that serves as a persistent data
store for this application.
This causes problems with data/time math. It also causes problems
related to Enterprise Objects Foundation (EOF). EOF receives
2006-01-01 08:00, but the "time" field in OpenBase stores only the
time portion. So when the value is read back from the database it is
based on the UNIX reference date.
------------------------------------------------------
--
Robert Walker
email@hidden
_______________________________________________
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