1 /////////////////////////////////////////////////////////////////////
2 ////schedule(time, nameOfFunction as String)
3 def schedule(String time, String nameOfFunction) {
4 //def _inputTime = time.split(':')
5 //Date date = new Date()
6 //def _currentTime = date.format("HH:mm:ss").split(':')
8 //Convert input time and current time to minutes
9 //def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
10 //def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
13 //if (inputTime < currentTime) {
14 // delay = 24*60*60-inputTime+currentTime
16 // delay = inputTime-currentTime
18 timersFuncList.add(nameOfFunction)
19 timersList.add(new SimulatedTimer())
20 def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(/*delay*1000*0*/0) {
24 ////schedule(time, nameOfFunction as Closure)
25 def schedule(String time, Closure nameOfFunction) {
26 //def _inputTime = time.split(':')
27 //Date date = new Date()
28 //def _currentTime = date.format("HH:mm:ss").split(':')
30 //Convert input time and current time to minutes
31 //def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
32 //def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
35 //if (inputTime < currentTime) {
36 // delay = 24*60*60-inputTime+currentTime
38 // delay = inputTime-currentTime
41 if (timersFuncList.contains(nameOfFunction)) {
42 timersList[timersFuncList.indexOf(nameOfFunction)].cancel()
43 def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(/*delay*0*/0, nameOfFunction0)
45 timersFuncList.add(nameOfFunction)
46 timersList.add(new SimulatedTimer())
47 def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(/*delay*0*/0, nameOfFunction)