• 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: Adding 30 minutes to an NSDate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding 30 minutes to an NSDate


  • Subject: Re: Adding 30 minutes to an NSDate
  • From: "Sean McBride" <email@hidden>
  • Date: Wed, 20 Jul 2005 13:48:54 -0400
  • Organization: Rogue Research

On 2005-07-20 19:27, Uli Kusterer said:

>> Doesn't -[NSCalendarDate
>> dateByAddingYears:months:days:hours:minutes:seconds:] work for you?
>
>Um, not quite. My problem is that I want it to be exact. If I add a
>certain number of hours, I'll get drift over time. So, I guess my
>question wasn't quite correctly formulated. But I just realised that
>I can probably use a hybrid approach, where I create my date by
>pinning the current date to the half-hour mark and then using the
>above function. That will take care of all the nastiness while still
>being exact.

Another thing to think about: the user changing the date in Sys Prefs
and/or automatic time change because of daylight savings time.
NSTimer's setFireDate: is a bit misleading.  Even though you give it a
precise date and time, it actually computes the interval until that time
and fires at _that time_.  So if it is 18h00 and you call setFireDate:
19h00 then the user changes the clock forward one half hour to 18h30,
the timer will go off at 19h30.  Clear as mud? :)

(Back to the old conversation about "documentation frustrations"... the
above is the kind of thing that needs to be in the Cocoa docs.
Currently the docs for setFireDate are merely:

setFireDate:
- (void)setFireDate:(NSDate *)date
Resets the receiver to fire next at date.

Which is almost useless.  Wow, setFireDate sets the firing date, who'd
have thought? :) )

Detecting the user changing the time can be done with a Carbon event,
it's in the archives.

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
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

References: 
 >Adding 30 minutes to an NSDate (From: Uli Kusterer <email@hidden>)
 >Re: Adding 30 minutes to an NSDate (From: j o a r <email@hidden>)
 >Re: Adding 30 minutes to an NSDate (From: Uli Kusterer <email@hidden>)

  • Prev by Date: [ANN] Silicon Valley CocoaHeads forming
  • Next by Date: Re: Adding 30 minutes to an NSDate
  • Previous by thread: Re: Adding 30 minutes to an NSDate
  • Next by thread: Re: Adding 30 minutes to an NSDate
  • Index(es):
    • Date
    • Thread