time.h critique

Joseph S. Myers jsm28 at cam.ac.uk
Fri Oct 2 13:28:28 UTC 1998


On Fri, 2 Oct 1998, Markus Kuhn wrote:

> Dave Flater wrote on 1998-09-21 18:57 UTC:

> > Other things that are not "broken" but that you might want to do:
> > 
> >    * Add an explicit interval type, an extended difftime function that
> >      takes two xtimes and returns an interval, and the other obvious
> >      operations.  I defined a bunch of operations over timestamps and
> >      intervals in C++ for XTide 2.0 but for C you probably want to
> >      keep it simple.
> 
> These are indeed rather simple to add, but what would be their semantics
> in the presence of leap seconds?

Taking a difference between two times, or adding one to a time, would need
a parameter to give the clock type; if this is TIME_UTC and the
implementation cannot determine whether there was a leap second in the
relevant interval an error would need to be signalled.

Note that a basic design principle is (should be) that leap seconds should
not need to feature directly in code using the library: programs should
need only be careful to use the correct clock types (which for time
differences will often be TIME_MONOTONIC) and degrade gracefully on
systems which have no leap second table or no time synchronisation.

-- 
Joseph S. Myers
jsm28 at cam.ac.uk




More information about the tz mailing list