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