Jeremyβs decision is really elegant, but it does not take into account daylight saving time. To protect yourself from this, you must trigger a timer event every hour and check the wall clock. Calculate the delta of the target, as suggested by Jeremy, and if it falls within the next hour, set a timer for shooting and turn off the hourly timer.
If not, just wait until the hourly timer lights up again.
Pseudo code: Get wall clock time Calculate difference between target time and wall clock If difference < 1 hour: Set timer to fire after difference secs If this is a repeating event, restart the hourly timer Else: Start watch timer to do this calculation again after one hour
Kurt pattyn
source share