freebsd-dev/lib/libc/stdtime
Peter Wemm ee4dc2a402 struct tm.tm_year is listed as 'years since 1900', and is signed. On
64 bit systems, years roughly -2^31 through 2^31 can be represented in
time_t without any trouble.  32 bit time_t systems only range from
roughly 1902 through 2038.  As a consequence, none of the date munging
code for all the various calendar tweaks before then is present.  There
are other problems including the fact that there was no 'year zero' and
so on.  So rather than get excited about trying to figure out when the
calendar jumped by two weeks etc, simply disallow negative (ie: prior to
1900) years.

This happens to have an important side effect.  If you bzero a 'struct
tm', it corresponds to 'Jan 0, 1900, 00:00 GMT'.  This happens to be
representable (after canonification) in 64 bit time_t space.  Zero tm
structs are generally an error and mktime normally returns -1 for them.
Interestingly, it tries to canonify the 'jan 0' to 'dec 31, 1899', ie:
year -1.  This conveniently trips the negative year test above, which
means we can trivially detect the null 'tm' struct.

This actually tripped up code at work. :-/  (Don't ask)
2004-08-24 00:15:37 +00:00
..
asctime.c Merge changes from the tzcode2004a import. Wherever possible I tried to bring 2004-06-14 10:31:52 +00:00
ctime.3 Mechanically kill hard sentence breaks. 2004-07-02 23:52:20 +00:00
difftime.c Merge changes from the tzcode2004a import. Wherever possible I tried to bring 2004-06-14 10:31:52 +00:00
localtime.c struct tm.tm_year is listed as 'years since 1900', and is signed. On 2004-08-24 00:15:37 +00:00
Makefile.inc libc_r wasn't so tied to libc for 22 months. 2002-11-18 09:50:57 +00:00
private.h Merge changes from the tzcode2004a import. Wherever possible I tried to bring 2004-06-14 10:31:52 +00:00
strftime.3 Mechanically kill hard sentence breaks. 2004-07-02 23:52:20 +00:00
strftime.c Merge changes from the tzcode2004a import. Wherever possible I tried to bring 2004-06-14 10:31:52 +00:00
strptime.3 Mechanically kill hard sentence breaks. 2004-07-02 23:52:20 +00:00
strptime.c Detect range errors when using the %s specifier. Previously, LONG_MAX 2003-11-17 04:19:15 +00:00
time2posix.3 mdoc(7) police: Use the new .In macro for #include statements. 2001-10-01 16:09:29 +00:00
time32.c Move dillon's time conversion functions to a new header <timeconv.h>. 2002-06-17 01:42:33 +00:00
timelocal.c Fixes to locale code to properly use indirect pointers in order to prevent 2003-06-13 00:14:07 +00:00
timelocal.h * style(9)'fy 2002-01-24 15:07:44 +00:00
tzfile.5 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 13:41:46 +00:00
tzfile.h Fix the style of the SCM ID's. 2002-03-22 23:42:05 +00:00