• 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: Alternative to NSDate's dateWithNaturalLanguageString: ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternative to NSDate's dateWithNaturalLanguageString: ?


  • Subject: Re: Alternative to NSDate's dateWithNaturalLanguageString: ?
  • From: David Arve <email@hidden>
  • Date: Tue, 1 Jul 2008 08:05:42 +0200


On Jun 30, 2008, at 5:14 PM, Jens Alfke wrote:


On 30 Jun '08, at 12:29 AM, David Arve wrote:

sqlite3_bind_int(sql_statement, 1, one_week);

Shouldn't that be sqlite3_bind_double? The variable one_week is declared as double, and I'm pretty sure that seconds-since-1970 intervals are soon going to overflow a (signed) 32-bit int, if they haven't already.

Erhm, yeah sloppy copy-paste that went wrong.



Is there a better way for me to get e.g. the dates from my database from
this week, this month etc.?

Look at "Calendars" in the "Date & Time Programming Guide For Cocoa", which describes how to do manipulations with calendar dates. In a nutshell, you can find the beginning of the week by getting the current date/time, then breaking it into components and setting the day-of-week plus hour/minute/second to zero, then converting back to NSDate. Then you can call -timeIntervalSince1970.


(I'd give you an example, but my own code that does this uses the deprecated NSCalendarDate class. I haven't used NSCalendar myself, yet.)

—Jens

Thanks!

/David

_______________________________________________

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


References: 
 >Alternative to NSDate's dateWithNaturalLanguageString: ? (From: "David Arve" <email@hidden>)
 >Re: Alternative to NSDate's dateWithNaturalLanguageString: ? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Problem in Custom Window
  • Next by Date: Re: Implementing NSOutlineView autosaveExpandedItems with CoreData
  • Previous by thread: Re: Alternative to NSDate's dateWithNaturalLanguageString: ?
  • Next by thread: Process app.
  • Index(es):
    • Date
    • Thread