Skip to content

Commit 33df887

Browse files
committed
fix: normalize hour=24 to 0 in cron date parts (Node 20 Intl bug)
In Node 20, Intl.DateTimeFormat with hourCycle='h23' can return '24' instead of '00' for midnight. This caused computeNextCronRunAt to never match hour=0 expressions (e.g. '0 0 * * 0'), exhausting the search loop and throwing. Normalize rawHour === 24 to 0 to fix.
1 parent e8b59c6 commit 33df887

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/scheduled-task/next-run.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ function getZonedDateParts(date: Date, timezone: string): ZonedDateParts {
197197
const year = Number(parts.find((part) => part.type === "year")?.value);
198198
const month = Number(parts.find((part) => part.type === "month")?.value);
199199
const day = Number(parts.find((part) => part.type === "day")?.value);
200-
const hour = Number(parts.find((part) => part.type === "hour")?.value);
200+
const rawHour = Number(parts.find((part) => part.type === "hour")?.value);
201+
const hour = rawHour === 24 ? 0 : rawHour;
201202
const minute = Number(parts.find((part) => part.type === "minute")?.value);
202203
const weekdayName = parts
203204
.find((part) => part.type === "weekday")

0 commit comments

Comments
 (0)