unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#26164: time-difference mishandles leap seconds
@ 2017-03-18 22:41 Zefram
  2017-04-19 14:32 ` Andy Wingo
  2018-10-21 22:56 ` Mark H Weaver
  0 siblings, 2 replies; 8+ messages in thread
From: Zefram @ 2017-03-18 22:41 UTC (permalink / raw)
  To: 26164

Computing the duration of the period between two UTC times, using
SRFI-19 mechanisms:

scheme@(guile-user)> (use-modules (srfi srfi-19))
scheme@(guile-user)> (define t0 (date->time-utc (make-date 0 59 59 23 30 6 2012 0))) 
scheme@(guile-user)> (define t1 (date->time-utc (make-date 0 1 0 0 1 7 2012 0)))
scheme@(guile-user)> (time-difference t1 t0)
$1 = #<time type: time-duration nanosecond: 0 second: 2>

The two times are 2012-06-30T23:59:59 and 2012-07-01T00:00:01, so at
first glance one would expect the duration to be 2 s as shown above,
the two seconds being 23:59:59 and 00:00:00.  But in fact there was
a leap second 2012-06-30T23:59:60, so the duration of this period is
actually 3 s.  The SRFI-19 library is aware of this leap second, and
will compute the duration correctly if it's translated into TAI:

scheme@(guile-user)> (time-difference (time-utc->time-tai t1) (time-utc->time-tai t0))
$2 = #<time type: time-duration nanosecond: 0 second: 3>

The original computation in UTC space should yield a result of 3 s,
not the 2 s that it did.  Since 1972, the seconds of UTC are of exactly
the same duration as the seconds of TAI.  (They're also phase-locked to
TAI seconds.)  Thus the period of three TAI seconds is also a period of
three UTC seconds.  It is not somehow squeezed into two UTC seconds.

-zefram





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-06  0:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 22:41 bug#26164: time-difference mishandles leap seconds Zefram
2017-04-19 14:32 ` Andy Wingo
2017-04-19 16:22   ` Zefram
2018-10-21 22:56 ` Mark H Weaver
2018-11-05 11:02   ` Zefram
2018-11-05 13:47     ` John Cowan
2018-11-05 20:46     ` Mark H Weaver
2018-11-06  0:12     ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).