• 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
Re: Date-Only NSTimestamps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date-Only NSTimestamps


  • Subject: Re: Date-Only NSTimestamps
  • From: David LeBer <email@hidden>
  • Date: Wed, 2 Jan 2008 15:37:18 -0500


On 2-Jan-08, at 3:18 PM, Chuck Hill wrote:


On Jan 2, 2008, at 12:01 PM, David Avendasora wrote:

Hi all,

I am working on some date-related calculations for a report. On the report the user specifies a date, and I want to match to a NSTimestamp-typed attribute in my Entity. The problem is that, of course, the attribute also contains time information which for this report is meaningless.

I've come up with a couple ways to achieve what I'm trying to do, and they seem to work, but they feel _very_ clunky and overly difficult, which brings me back to the old WO axiom: if it's hard, you're probably not doing it the WO-way.

That is a mis-quote. The actual axiom is "if it's hard, you're probably not doing it the WO-way unless you are working with dates". :-)

I was going to say the same thing. To be fair to WO, Java dates are a pain for everyone. Though why they had to deprecate all of the date utility methods in NSTimestamp I'll never know (OK, I actually do know, more compatible with pure Java and all that, doesn't mean I like it).


So, what are the best practices for working with an NSTimestamp field, when all you really want is the date, not the time?


There isn't any that I am aware of. I usually "normalize" these to noon in the setXXXDate() methods.

Oooh, that Chuck, he's a smart one!

I have a bunch of NSTimestamp utility methods like startOfDay and endOfDay that I use to create qualifiers with (sudo qualifier: entity.theDate >= TSUtilities.startOfDay(theQueryDate) && entity.theDate <= TSUtilities.endOfDay(theQueryDate)).

Yes, it's fugly... Depending on your needs Chuck's solution is probably vastly less so.

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Date-Only NSTimestamps
      • From: Simon McLean <email@hidden>
    • Re: Date-Only NSTimestamps
      • From: Chuck Hill <email@hidden>
References: 
 >Date-Only NSTimestamps (From: David Avendasora <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Date-Only NSTimestamps
  • Next by Date: Re: Date-Only NSTimestamps
  • Previous by thread: Re: Date-Only NSTimestamps
  • Next by thread: Re: Date-Only NSTimestamps
  • Index(es):
    • Date
    • Thread