• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Time creation and storage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Time creation and storage
      • From: Greg Herlihy <email@hidden>
  • Prev by Date: Re: Highlighting a valid drop target (serious dead end)
  • Next by Date: Re: Highlighting a valid drop target (serious dead end)
  • Previous by thread: NSTokenField automatically selecting all
  • Next by thread: Re: Time creation and storage
  • Index(es):
    • Date
    • Thread