[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 02/02: timer: ‘seconds-to-wait’ returns an inexact number.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 02/02: timer: ‘seconds-to-wait’ returns an inexact number. |
Date: |
Sat, 30 Mar 2024 17:56:58 -0400 (EDT) |
civodul pushed a commit to branch devel
in repository shepherd.
commit eef2face02bd55f8382a9759d351c7875f22a4db
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Mar 30 22:21:18 2024 +0100
timer: ‘seconds-to-wait’ returns an inexact number.
* modules/shepherd/service/timer.scm (seconds-to-wait)[next-second]: Remove.
Return an inexact number.
---
modules/shepherd/service/timer.scm | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/modules/shepherd/service/timer.scm
b/modules/shepherd/service/timer.scm
index 9abcebb..ccaa790 100644
--- a/modules/shepherd/service/timer.scm
+++ b/modules/shepherd/service/timer.scm
@@ -281,16 +281,12 @@ event record."
(define (seconds-to-wait event)
"Return the number of seconds to wait before the next occurrence of
-@var{event} (the result is always greater than zero)."
- (define (next-second time)
- (make-time time-utc
- (time-nanosecond time) (+ 1 (time-second time))))
-
- (let* ((now (next-second (current-time time-utc)))
+@var{event} (the result is an inexact number, always greater than zero)."
+ (let* ((now (current-time time-utc))
(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))))
+ (+ (time-second diff)
+ (/ (time-nanosecond diff) 1e9))))
(define (cron-string->calendar-event str)
"Convert @var{str}, which contains a Vixie cron date line, into the