emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Represent NTP's origin time


From: Stefan Monnier
Subject: Re: Represent NTP's origin time
Date: Thu, 15 Apr 2021 08:40:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> NTP represents time stamps by counting seconds from January 1 1900, but
>> my Emacs doesn't seem to be able to represent this:
>
>>     (encode-time (parse-time-string "1902-01-01T00:00-00:00"))
>>     => (-32745 59520)
>>     (encode-time (parse-time-string "1900-01-01T00:00-00:00"))
>>     => (error "Specified time is not representable")
>
>> Do we have some "standard" workaround?
>
> Overflow in the underlying mktime(3) or mktime_z(3)? Are there still
> systems around where time_t has only 32 bits?

AFAIK all GNU/Linux i386 installations do.  Nowadays amd64 is more
common, but most of my machines are still running an i386 image and I'm
pretty sure I'm not the only one.

Also all armhf GNU/Linux systems do, and machines for which this is the
main/sole option are still being produced.

So, getting back to the question: Do we have some "standard" workaround?
I don't actually need to represent times from the early 20th century,
but I need to compute NTP timestamps.  I can come up with my own
workaround (e.g. hardcoding as a "magic constant" the number of seconds
between NTP's origin time and some arbitrary other origin time of my
choosing which 32bit systems can represent), but I was hoping we already
have something like that somewhere.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]