Oh fun. The unit tests, that passed two days ago, today fail on Alpine Linux, macOS, *BSD, Solaris 11 OmniOS, native Windows, because for the input "Friday" getdate() returns 2026-11-34.
FAIL: test-getdate ================== ../../gltests/test-getdate.c:134: assertion 't->tm_year >= 1970 - 1900 && t->tm_mon >= 0 && t->tm_mon < 12 && t->tm_mday >= 1 && t->tm_mday <= 31 && t->tm_wday == 5 && t->tm_hour == 12 && t->tm_min == 0 && t->tm_sec == 0' failed ../../gltests/test-getdate.c:145: assertion 't->tm_year >= 1970 - 1900 && t->tm_mon >= 0 && t->tm_mon < 12 && t->tm_mday >= 1 && t->tm_mday <= 31 && t->tm_wday == 5 && t->tm_hour >= 0 && t->tm_hour < 24 && t->tm_min >= 0 && t->tm_min < 60 && t->tm_sec >= 0 && t->tm_sec < 60' failed ../../gltests/test-getdate.c:184: assertion 't->tm_year >= 1970 - 1900 && t->tm_mon >= 0 && t->tm_mon < 12 && t->tm_mday >= 1 && t->tm_mday <= 31 && t->tm_wday == 5 && t->tm_hour >= 0 && t->tm_hour < 24 && t->tm_min >= 0 && t->tm_min < 60 && t->tm_sec >= 0 && t->tm_sec < 60' failed ../../gltests/test-getdate.c:285: assertion 't->tm_year >= 1970 - 1900 && t->tm_mon >= 0 && t->tm_mon < 12 && t->tm_mday >= 1 && t->tm_mday <= 31 && t->tm_wday == 5 && t->tm_hour == 9 && t->tm_min == 0 && t->tm_sec == 0' failed FAIL test-getdate (exit status: 1) This patch fixes it. 2026-11-28 Bruno Haible <[email protected]> getdate: Fix test failures that occur near the end of a month. * lib/getdate.c (__getdate_r): Normalize *TP, like glibc does. diff --git a/lib/getdate.c b/lib/getdate.c index f909f55930..a1b302544e 100644 --- a/lib/getdate.c +++ b/lib/getdate.c @@ -315,13 +315,10 @@ __getdate_r (const char *string, struct tm *tp) /* Check if the day of month is within range, and if the time can be represented in a time_t. We make use of the fact that the mktime - call normalizes the struct tm. But do not normalize *TP, because - that could increment TP->tm_hour due to DST, and this is undesired - here. */ - struct tm tmp; + call normalizes the struct tm. */ if ((!mday_ok && !check_mday (TM_YEAR_BASE + tp->tm_year, tp->tm_mon, tp->tm_mday)) - || (tmp = *tp, __mktime64 (&tmp) == (time_t) -1)) + || __mktime64 (tp) == (time_t) -1) return 8; return 0;
