[LEAPSECS] EBML: yet another date format?

Poul-Henning Kamp phk at phk.freebsd.dk
Sat Jun 27 12:21:33 EDT 2015


--------
In message <558ECBD0.26744.17A6489F at dan.tobias.name>, "Daniel R. Tobias" writes
:

>The way dates are defined there is:
>
>     signed 8 octets integer in nanoseconds with 0
>	indicating the precise beginning of the
>	millennium (at 2001-01-01T00:00:00.000000000 UTC)

The bit which confuses me here, as with timespec and timeval is
why the f**k people seem to love mixed radixes for time ?

Numeric timeformats for binary computers should be fixed point
binary and have units of seconds.

That way you can have multiple different formats for different needs
(32.32, 48.16, 64.32, 64.64 ...) and still painlessly convert between
them.

But more importantly: you can do arithmetic on them at machine
speed, instead of having to use horrors such as:

#define timespeccmp(tvp, uvp, cmp)                                              (((tvp)->tv_sec == (uvp)->tv_sec) ?                                         ((tvp)->tv_nsec cmp (uvp)->tv_nsec) :                                   ((tvp)->tv_sec cmp (uvp)->tv_sec))
#define timespecadd(vvp, uvp)                                                   do {                                                                            (vvp)->tv_sec += (uvp)->tv_sec;                                         (vvp)->tv_nsec += (uvp)->tv_nsec;                                       if ((vvp)->tv_nsec >= 1000000000) {                                             (vvp)->tv_sec++;                                                        (vvp)->tv_nsec -= 1000000000;                                   }                                                               } while (0)
#define timespecsub(vvp, uvp)                                                   do {                                                                            (vvp)->tv_sec -= (uvp)->tv_sec;                                         (vvp)->tv_nsec -= (uvp)->tv_nsec;                                       if ((vvp)->tv_nsec < 0) {                                                       (vvp)->tv_sec--;                                                        (vvp)->tv_nsec += 1000000000;                                   }                                                       
And that's why the above is bogus, even before we discuss their choice
of epoch or handling of leapseconds...

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the LEAPSECS mailing list