Going backwards from "cal 1 1" you can see that in
the Julian calendar 01-Jan-0000 was a Thursday, but that's not so
relevant.
However cal can help seeing that 01-Jan-0000 is a Saturday in
Gregorian proleptic calendar (i.e. extending Gregorian calendar before
the day when it was adopted). 400 years have 146097 days, which is
divisible by 7, and 01-Jan-2000 was a Saturday.
If that's true, then this new test failure suggests there's a bug in mktime.
For the record, GNU Smalltalk gives the same answer.
But mktime seems to work here:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
const char days[7][4] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
struct tm tm;
time_t t;
memset (&tm, 0, sizeof (tm));
tm.tm_mon = 0;
tm.tm_mday = 1;
tm.tm_year = -1900;
setenv ("TZ", "GMT");
t = mktime (&tm);
printf ("%ld\n", t);
printf ("%s %d\n", days[tm.tm_wday], tm.tm_yday);
printf ("%s", ctime(&t));
tm = *gmtime(&t);
printf ("%d %d %d %s\n", tm.tm_mon, tm.tm_mday, tm.tm_year,
days[tm.tm_wday]);
}
$ ./a.out
-62167219200
Sat 0
Sat Jan 1 00:00:00 0
0 1 -1900 Sat
Paolo