[RFC PATCH 51/52] Y2038: add RPC functions

Paul Eggert eggert@cs.ucla.edu
Mon Sep 11 06:33:00 GMT 2017


Albert ARIBAUD wrote:
> time_t is a signed int, but its negative range is not completely
> usable since (time_t)-1 is used as an error status. So should the
> TIME_T_MIN limit be LONG_MIN or should it be 0?

Definitely LONG_MIN. Functions like localtime accept -1 as valid input meaning 
1969-12-31 23:59:59 UTC.

Even for some functions like mktime that return -1 as an error indicator, -1 can 
also be a valid (non-error) return value. I help maintain application code that 
can tell the difference between the two seemingly-identical -1s that mktime 
returns, so that the time_t range is completely usable there too. Admittedly 
it's not an ideal API.



More information about the Libc-alpha mailing list