[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 03/05: timer: Improve rounding in ‘seconds-to-wait’.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 03/05: timer: Improve rounding in ‘seconds-to-wait’. |
Date: |
Thu, 28 Mar 2024 15:39:07 -0400 (EDT) |
civodul pushed a commit to branch devel
in repository shepherd.
commit a2d1018c8da9ae2353e90833fadfd49a31ec0cea
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Mar 27 23:19:49 2024 +0100
timer: Improve rounding in ‘seconds-to-wait’.
* modules/shepherd/service/timer.scm (seconds-to-wait): Take nanoseconds
in account to round the result.
---
modules/shepherd/service/timer.scm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/modules/shepherd/service/timer.scm
b/modules/shepherd/service/timer.scm
index e5489d7..9a26ac7 100644
--- a/modules/shepherd/service/timer.scm
+++ b/modules/shepherd/service/timer.scm
@@ -284,8 +284,10 @@ event record."
(time-nanosecond time) (+ 1 (time-second time))))
(let* ((now (next-second (current-time time-utc)))
- (then (next-calendar-event event (time-utc->date now))))
- (+ 1 (time-second (time-difference (date->time-utc then) now)))))
+ (then (next-calendar-event event (time-utc->date now)))
+ (diff (time-difference (date->time-utc then) now)))
+ (+ 1 (time-second diff)
+ (if (>= (time-nanosecond diff) 5e8) 1 0))))
;;;