Fix some minor time-related bugs with POSIX time arguments.
authorJim Meyering <jim@meyering.net>
Mon, 2 Jun 2003 08:20:57 +0000 (08:20 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 2 Jun 2003 08:20:57 +0000 (08:20 +0000)
commitb20a6a6e55940a5219dfe54a84f8a5abed5fa1b6
treec1b66db3e8104476e52aab00f08158b5e0544c32
parent6fee07751246e20d4f8442500b989c148760b38a
Fix some minor time-related bugs with POSIX time arguments.
Some valid time stamps were being rejected (notably -1, and
time stamps before 1900 on 64-bit hosts).  And some invalid
time stamps were being accepted, e.g. September 31.

* posixtm.h (posixtime): Return bool instead of time_t, so
that we can return (time_t) -1 successfully.
* posixtm.c: Likewise.
[HAVE_STDBOOL_H]: Include <stdbool.h>.
(bool, false, true) [!HAVE_STDBOOL_H]: New type.
(t): Remove static var.
(year, posix_time_parse): Now takes struct tm * arg to modify, instead
of static var.  All uses changed.
(year): Do not reject years before 1900; they can occur with
64-bit time_t.
(posix_time_parse): Do not check for out-of-range components;
that is now the caller's responsibility, since our checks were
only approximations.
(posixtime): Use mktime to check for out-of-range components,
since it knows them exactly.
If mktime returns (time_t) -1, check whether an error actually occurred
by invoking localtime on -1.
(main) [TEST_POSIXTIME]: Check for input data errors, and report
posixtime failures better.
Improve the test data (in comments only).
lib/posixtm.c