Skip to content

Commit

Permalink
Update srfi/19 for latest leap seconds
Browse files Browse the repository at this point in the history
Closes PR 13390
  • Loading branch information
takikawa committed Jan 18, 2013
1 parent 15a73e2 commit 7e67959
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 26 deletions.
55 changes: 29 additions & 26 deletions collects/srfi/19/time.rkt
Expand Up @@ -216,33 +216,36 @@

;; each entry is ( utc seconds since epoch . # seconds to add for tai )
;; note they go higher to lower, and end in 1972.

;; added another one for 2006, based on random web-searching.
;;
;; up-to-date as of 2013-01-18
(define tm:leap-second-table
'((1136073600 . 33)
(915148800 . 32)
(867715200 . 31)
(820454400 . 30)
(773020800 . 29)
(741484800 . 28)
(709948800 . 27)
(662688000 . 26)
(631152000 . 25)
(567993600 . 24)
(489024000 . 23)
(425865600 . 22)
(394329600 . 21)
(362793600 . 20)
(315532800 . 19)
(283996800 . 18)
(252460800 . 17)
(220924800 . 16)
(189302400 . 15)
(157766400 . 14)
(126230400 . 13)
(94694400 . 12)
(78796800 . 11)
(63072000 . 10)))
'((1341100800 . 35) ; 2012-07-01
(1230768000 . 34) ; 2009-01-01
(1136073600 . 33) ; 2006-01-01
(915148800 . 32) ; 1999-01-01
(867715200 . 31) ; 1997-07-01
(820454400 . 30) ; 1996-01-01
(773020800 . 29) ; 1994-07-01
(741484800 . 28) ; 1993-07-01
(709948800 . 27) ; 1992-07-01
(662688000 . 26) ; 1991-01-01
(631152000 . 25) ; 1990-01-01
(567993600 . 24) ; 1988-01-01
(489024000 . 23) ; 1985-07-01
(425865600 . 22) ; 1983-07-01
(394329600 . 21) ; 1982-07-01
(362793600 . 20) ; 1981-07-01
(315532800 . 19) ; 1980-01-01
(283996800 . 18) ; 1979-01-01
(252460800 . 17) ; 1978-01-01
(220924800 . 16) ; 1977-01-01
(189302400 . 15) ; 1976-01-01
(157766400 . 14) ; 1975-01-01
(126230400 . 13) ; 1974-01-01
(94694400 . 12) ; 1973-01-01
(78796800 . 11) ; 1972-07-01
(63072000 . 10) ; 1972-01-01
))

(define (read-leap-second-table filename)
(set! tm:leap-second-table (tm:read-tai-utc-data filename))
Expand Down
21 changes: 21 additions & 0 deletions collects/tests/srfi/19/tests.rkt
Expand Up @@ -249,6 +249,27 @@
(check-equal? (srfi:date-year (srfi:make-date 0 0 0 0 1 1 2004 0))
2004))

;; test leap seconds
(test-case "check latest leap seconds"
(check-equal?
1230768032
(time-second (date->time-tai (srfi:make-date 0 59 59 23 31 12 2008 0))))
(check-equal?
1230768033
(time-second (date->time-tai (srfi:make-date 0 60 59 23 31 12 2008 0))))
(check-equal?
1230768034
(time-second (date->time-tai (srfi:make-date 0 0 0 0 1 1 2009 0))))
(check-equal?
1341100833
(time-second (date->time-tai (srfi:make-date 0 59 59 23 30 6 2012 0))))
(check-equal?
1341100834
(time-second (date->time-tai (srfi:make-date 0 60 59 23 30 6 2012 0))))
(check-equal?
1341100835
(time-second (date->time-tai (srfi:make-date 0 0 0 0 1 7 2012 0)))))

;; nanoseconds off by a factor of 100...
(test-case "nanosecond order-of-magnitude"
;; half a second should be within 1/10th of 10^9 / 2 nanoseconds (currently off by a factor of 100)
Expand Down

0 comments on commit 7e67959

Please sign in to comment.