calendarspec: day of month also needs to be reset when year is changed

Fixes #40260.
This commit is contained in:
Yu Watanabe
2026-01-04 09:37:46 +09:00
parent 82dea1c925
commit cf79f61238
2 changed files with 5 additions and 2 deletions

View File

@@ -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;

View File

@@ -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) {