return the precise scheduled execution time for timers (#3182)
When writing tests and mocking time, it can be important that execution_time match _exactly_ with what was sent to reschedule(). When re-calculating based on now and the expected remaining delay, this might be off by a few milliseconds. We have the exact time that was requested already, so might as well use it. Signed-off-by: Cody Cutrer <cody@cutrer.us>pull/3184/head
parent
af3738487c
commit
d96e5d5bc0
|
@ -13,7 +13,6 @@
|
|||
package org.openhab.core.automation.module.script.internal.action;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
@ -64,7 +63,7 @@ public class TimerImpl implements Timer {
|
|||
|
||||
@Override
|
||||
public @Nullable ZonedDateTime getExecutionTime() {
|
||||
return future.isCancelled() ? null : ZonedDateTime.now().plusNanos(future.getDelay(TimeUnit.NANOSECONDS));
|
||||
return future.isCancelled() ? null : future.getScheduledTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue