1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-27 21:40:34 +02:00

SRFI-19: Fix normalization of seconds and nanoseconds in time records.

Fixes <https://bugs.gnu.org/26162>.
Reported by Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm (time-normalize!): Rewrite.
* test-suite/tests/srfi-19.test: Add tests.
This commit is contained in:
Mark H Weaver 2018-10-21 19:21:47 -04:00 committed by Andy Wingo
parent 8361d59d1c
commit 0389c59bd4
2 changed files with 24 additions and 18 deletions

View file

@ -206,6 +206,14 @@ incomplete numerical tower implementation.)"
(test-time-arithmetic add-duration time1 diff time2)
(test-time-arithmetic subtract-duration time2 diff time1))
(with-test-prefix "nanosecond normalization"
(pass-if "small positive duration"
(time-equal? (make-time time-duration 999999000 0)
(time-difference (make-time time-tai 0 1) (make-time time-tai 1000 0))))
(pass-if "small negative duration"
(time-equal? (make-time time-duration -999999000 0)
(time-difference (make-time time-tai 1000 0) (make-time time-tai 0 1)))))
(with-test-prefix "date->time-tai"
;; leap second 1 Jan 1999, 1 second of UTC in make-date is out as 2
;; seconds of TAI in date->time-tai