Sujet : Re: Y2K38 bug (January 19, 2038)
De : geoff (at) *nospam* clare.See-My-Signature.invalid (Geoff Clare)
Groupes : comp.lang.awkDate : 12. Mar 2024, 14:34:11
Autres entêtes
Message-ID : <j726ck-3qt.ln1@ID-313840.user.individual.net>
References : 1 2 3 4 5
User-Agent : Pan/0.154 (Izium; 517acf4)
Keith Thompson wrote:
"Mr. Man-wai Chang" <toylet.toylet@gmail.com> writes:
On 9/3/2024 3:51 am, Keith Thompson wrote:
I'm a little disappointed that POSIX doesn't require time_t to be
signed. 64 bits is enough to represent a range of about 584 billion
years. An unsigned time_t makes it impossible to represent times before
1970.
>
Could we roll our own signed time_t? :)
I see the smiley, but I don't get the joke.
If you're creating your own implementation, you can do anything you
like. If not, and you're using an implementation that makes time_t an
unsigned type, there's not much you can do to treat it as signed. For
example, localtime() would presumably treat a time_t value of -2 as a
very large unsigned value.
I don't know of any implementations that make time_t an unsigned type.
QNX is one.
See
www.qnx.net/developers/docs/6.4.0/neutrino/sys_arch/kernel.html
which says:
Valid dates on a QNX Neutrino system range from January 1970 to at
least 2038. The time_t data type is an unsigned 32-bit number, which
extends this range for many applications through 2106.
Also, having signed time_t doesn't necessarily mean that dates before
Jan 1970 are supported. I seem to recall that MS Windows has signed
time_t but does not support negative values.
-- Geoff Clare <netnews@gclare.org.uk>