diff --git a/bedstead.c b/bedstead.c index 218523a..fe87a1a 100644 --- a/bedstead.c +++ b/bedstead.c @@ -3155,19 +3155,18 @@ time_for_ttx(void) if (!isdigit((unsigned char)epochstr[0]) || endptr == epochstr || *endptr != '\0' || errno == ERANGE || - /* Limit ourselves to 2000 to 10000. */ - epochumax < 946684800 || epochumax >= 253402300800) { + /* Allow years up to 9999. */ + epochumax >= 253402300800) { fprintf(stderr, "Invalid SOURCE_DATE_EPOCH\n"); return NULL; } - epochumax -= 946684800; /* Rebase to 2000. */ tm.tm_isdst = -1; tm.tm_sec = epochumax % 60; tm.tm_min = epochumax / 60 % 60; tm.tm_hour = epochumax / 3600 % 24; long day = epochumax / 86400; - tm.tm_wday = (day - 1) % 7; - int y = 2000 + (day / 146097) * 400; + tm.tm_wday = (day + 4) % 7; /* 1970-01-01 was a Thursday. */ + int y = 1970 + (day / 146097) * 400; day = day % 146097; bool ly; for (;;) {