1 /////////////////////////////////////////////////////////////////////
2 ////schedule(time, nameOfFunction as String)
3 def schedule(String time, String nameOfFunction) {
4 /*def _inputTime = time.split(':')
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) {
25 ////schedule(time, nameOfFunction as Closure)
26 def schedule(String time, Closure nameOfFunction) {
27 /*def _inputTime = time.split(':')
28 Date date = new Date()
29 def _currentTime = date.format("HH:mm:ss").split(':')
31 Convert input time and current time to minutes
32 def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
33 def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
36 if (inputTime < currentTime) {
37 delay = 24*60*60-inputTime+currentTime
39 delay = inputTime-currentTime
42 if (timersFuncList.contains(nameOfFunction)) {
43 timersList[timersFuncList.indexOf(nameOfFunction)].cancel()
44 def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(0, nameOfFunction)
46 timersFuncList.add(nameOfFunction)
47 timersList.add(new SimulatedTimer())
48 def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(0, nameOfFunction)