On Monday, August 11, 2003, at 02:04 PM, Robert Brenstein wrote:

convert it to dateitems
add 1 to item 5 of it # up hour to next
if item 5 of it is 24 then # account for crossing midnight
  put zero into item 5 of it
  add 1 to item 4 of it
  ## similar checks for month and year overflow here
end if
put zero into item 6 of it # zero out minutes
convert it to seconds

get (round(it/3600) + 1)*3600


Would this work?

Dar Scott


Nop. 'It' contains dateitems (yyyy,mm,dd,hh,mm,ss,w) not seconds at this point. But oops, my item refs are wrong. Here is the corrected code.


on fullhourchime
  play sound # first play
  get seconds()
  convert it to dateitems
  add 1 to item 4 of it # up hour to next
  if item 4 of it is 24 then # account for crossing midnight
    put zero into item 4 of it
    add 1 to item 3 of it
    if item 3 of it is ...
      ## check for month and then year overflow here
    end if
  end if
  put zero into item 5 of it # zero out minutes
  put zero into item 6 of it # zero out seconds
  convert it to seconds
  send fullhourchime to me in (it-seconds())
end fullhourchime

What this code does (for those less familiar with date/time conversions) is: it first gets the current seconds and converts them to dateitems. Then, it is a matter of increasing hour by 1 and setting minutes and seconds to 0. We have now next full hour, which we convert back to seconds and then ask to 'send' in whatever is the difference between the calculated seconds for next full hour and current seconds.

The only complication is that one needs to account for midnight (end of the day), end of the month, and end of the year. May be there is a way to avoid this somehow.

Robert
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to