]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'timer-next-integral-multiple-of-time'
authorEli Zaretskii <eliz@gnu.org>
Sat, 20 Oct 2018 09:52:52 +0000 (12:52 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 20 Oct 2018 09:52:52 +0000 (12:52 +0300)
* lisp/emacs-lisp/timer.el
(timer-next-integral-multiple-of-time): Fix recent change for
fractional values of SECS.  (Bug#33071)
* test/lisp/emacs-lisp/timer-tests.el
(timer-next-integral-multiple-of-time-2): New test.

lisp/emacs-lisp/timer.el
test/lisp/emacs-lisp/timer-tests.el

index 927e640feaa690e893347c5b05c52490bf5a39d9..e140738d9f31ef13eae649b3e0b4fe1d126f1967 100644 (file)
@@ -101,7 +101,7 @@ of SECS seconds since the epoch.  SECS may be a fraction."
                       time
                     (encode-time time 1000000000000)))
         (hz (cdr ticks-hz))
-        (s-ticks (* secs hz))
+        (s-ticks (round (* secs hz)))
         (more-ticks (+ (car ticks-hz) s-ticks)))
     (encode-time (cons (- more-ticks (% more-ticks s-ticks)) hz))))
 
index c5971ee7687e92c628fa9f2bc69ffda1f1dc7607..7a5b9263b0bc93b1622366c2264969bc94682587 100644 (file)
           (timer-next-integral-multiple-of-time '(0 0 0 1) (1+ (ash 1 53)))
           (list (ash 1 (- 53 16)) 1))))
 
+(ert-deftest timer-next-integral-multiple-of-time-2 ()
+  "Test bug#33071."
+  (let* ((tc (current-time))
+         (tce (encode-time tc 100))
+         (nt (timer-next-integral-multiple-of-time tc 0.01))
+         (nte (encode-time nt 100)))
+    (should (= (car nte) (1+ (car tce))))))
+
 ;;; timer-tests.el ends here