1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

(date->time-tai): New tests, exercising new leap-second.

This commit is contained in:
Kevin Ryde 2005-08-18 23:52:35 +00:00
parent 812435bee2
commit cb94db4374

View file

@ -88,6 +88,12 @@ incomplete numerical tower implementation.)"
(pass-if (format #f "~A works" op)
(time=? (op a b) res)))
;; return true if time objects X and Y are equal
(define (time-equal? x y)
(and (eq? (time-type x) (time-type y))
(eqv? (time-second x) (time-second y))
(eqv? (time-nanosecond x) (time-nanosecond y))))
(with-test-prefix "SRFI date/time library"
;; check for typos and silly errors
(pass-if "date-zone-offset is defined"
@ -152,6 +158,25 @@ incomplete numerical tower implementation.)"
(test-time-arithmetic add-duration time1 diff time2)
(test-time-arithmetic subtract-duration time2 diff time1))
(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
(pass-if "31dec98 23:59:59"
(time-equal? (make-time time-tai 0 915148830)
(date->time-tai (make-date 0 59 59 23 31 12 1998 0))))
(pass-if "1jan99 0:00:00"
(time-equal? (make-time time-tai 0 915148832)
(date->time-tai (make-date 0 0 0 0 1 1 1999 0))))
;; leap second 1 Jan 2006, 1 second of UTC in make-date is out as 2
;; seconds of TAI in date->time-tai
(pass-if "31dec05 23:59:59"
(time-equal? (make-time time-tai 0 1136073631)
(date->time-tai (make-date 0 59 59 23 31 12 2005 0))))
(pass-if "1jan06 0:00:00"
(time-equal? (make-time time-tai 0 1136073633)
(date->time-tai (make-date 0 0 0 0 1 1 2006 0)))))
(with-test-prefix "date-week-number"
(pass-if "1Jan84"
(= 0 (date-week-number (make-date 0 0 0 0 1 1 1984 0) 0)))