From: Yu Watanabe Date: Sun, 4 Jan 2026 00:37:46 +0000 (+0900) Subject: calendarspec: day of month also needs to be reset when year is changed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf79f61238fa812d1850987e04d3767ce71dd972;p=thirdparty%2Fsystemd.git calendarspec: day of month also needs to be reset when year is changed Fixes #40260. --- diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c index 88a4467187c..dc13ae0f779 100644 --- a/src/shared/calendarspec.c +++ b/src/shared/calendarspec.c @@ -1194,9 +1194,10 @@ static int tm_within_bounds(struct tm *tm, bool utc) { * other sub time units are already reset in find_next(). */ int cmp; - if ((cmp = CMP(t.tm_year, tm->tm_year)) != 0) + if ((cmp = CMP(t.tm_year, tm->tm_year)) != 0) { t.tm_mon = 0; - else if ((cmp = CMP(t.tm_mon, tm->tm_mon)) != 0) + t.tm_mday = 1; + } else if ((cmp = CMP(t.tm_mon, tm->tm_mon)) != 0) t.tm_mday = 1; else if ((cmp = CMP(t.tm_mday, tm->tm_mday)) != 0) t.tm_hour = 0; diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index 0b1cbacd625..6c901b1893c 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -219,6 +219,8 @@ TEST(calendar_spec_next) { test_next("Sun *-*-* 01:00:00 Europe/Dublin", "IST", 1616412478000000, 1617494400000000); /* Europe/Dublin TZ that moves DST backwards */ test_next("hourly", "IST-1GMT-0,M10.5.0/1,M3.5.0/1", 1743292800000000, 1743296400000000); + /* Check when the year changes, see issue #40260 */ + test_next("*-*-1/11 23:00:00 UTC", "", 1763938800000000, 1764630000000000); } TEST(calendar_spec_from_string) {