I need a quick implementation of the "Date Transition" algorithm, which should be included in the event management system.
The event is triggered and sets the date (in a synchronized manner) to the next 10th minute.
for instance
Event occurs at "2010-01-05 13:10:12" and sets the next date to be "2010-01-05 13:20:00"
and if the event occurs exactly (presumably) in the 10th minute, the next should be set
Event occurs at "2010-01-05 13:30:00" and sets the next date to be "2010-01-05 13:40:00"
(unlikely, as the date drops to 1 / 1000th of a second, but just in case ...).
My first idea would be to get the current Date() and work directly with ms from the getTime () method using integer (long) division, e.g. ((time / 10mn)+1)*10mn .
Since it should be fast as well as reliable, I thought I would ask my OSers assistants before implementation.
source share