• 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: Best way to check for hour?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to check for hour?


  • Subject: Re: Best way to check for hour?
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sat, 21 Apr 2001 19:42:56 -0400
  • Organization: [very little]

> Date: Fri, 20 Apr 2001 21:06:24 -0800
> Subject: Re: Best way to check for hour?
> From: g3pb <email@hidden>
> To: "Stephen Swift (aka Burnum)" <email@hidden>, AppleScript
> <email@hidden>
>
> use a scheduling program such as iDo or Nag
>
> -- hcir
> mailto:email@hidden
>
> > I need a script to do something during the hour of 12 AM & PM. I can get it
> > to check for the hour, but I'm not sure the best way. Is there a better way
> > that having an idle statement check every hour? Thanks.

While I agree that iDo or nag is the best approach, just for fun I wrote
this script. When you start it, it will "do stuff" only if the time is
between midnight and 1 AM or noon and 1 PM. After that it triggers
every noon and midnight. Because it schedules its "return" based on a
twelve hour cycle, it only becomes active at those times. This is
completely UNtested...

global nextTime

on run
set nextTime to ""
end run

on idle
if nextTime is "" then
set startTime to date "00:00" of (current date)
if (current date) - startTime < (12 * hours) then
set nextTime to startTime
else
set nextTime to startTime + (12 * hours)
end if
end if
if (current date) - nextTime < (1 * hours) then
-- do stuff
end if
set nextTime to nextTime + (12 * hours)
return (nextTime - (current date))
end idle

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[4/21/01 7:40:09 PM]


  • Prev by Date: Re: Handlers in list
  • Next by Date: Copy To iDisk
  • Previous by thread: Re: Best way to check for hour?
  • Next by thread: Scripting Programs Linking - CRITICAL!!!
  • Index(es):
    • Date
    • Thread