val fred = now
val duration = 10
createTimer(now.plusMinutes(duration)) [ |
logInfo("test", "timer was started " + fred.toString)
logInfo("test", "duration was " + duration.toString)
]
I’m trying to figure out how to account for the ‘reschedule’. Do you recommend to just add the minutes to a number variable with each reschedule rather than calculate the actual elapsed time based on the original ‘now’?
Well, you can’t add to the val, and you can’t use a var created inside the rule in this way.
You could use a ‘global’ var,but only if you are using xxx.rules files.
If you have many, that could take the form of a Map (“array”) as you suggested to begin with.
Or the timestamp works, just find the difference to current ‘now’ as and when required.
Possibly useful methods
or the traditional way is to convert everything to epoch milliseconds and do simple arithmetic.