Is their a simple way to detect if the actual time (in hour) is near one of 4 hours?
I've got an AS3 code that calculate and displays 4 tides (changing everyday). Example :
High 1 = 13h20
High 2 = 23h30
Low 1 = 05h30
Low 2 = 16h20
In code, I'm not gonna put here the calculation of the tides as it's too long and not necessary for this problem, but the variables are :
var $pmm:String;
var $pms:String;
var $bmm:String;
var $bms:String;
High 1 = $pmm
High 2 = $pms
Low 1 = $bmm
Low 2 = $bms
The app also displays the actual time
var my_timer:Timer=new Timer(1000);
my_timer.addEventListener(TimerEvent.TIMER, onTimer);
my_timer.start();
function onTimer(e:TimerEvent😞void {
now = new Date();
trace(now.hours + ":" + now.minutes);
}
Is there a simple way to detect if now.hours is closest to $pmm, $pms, $bmm or $bms when the user open the app ?
