Skip to content

Commit 51f8db7

Browse files
t3dotggclaude
andcommitted
fix(contracts): check calendar days without new Date
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7b7e870 commit 51f8db7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎packages/contracts/src/scheduledTask.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ function isIsoWithOffset(value: string): boolean {
5353
const match = ISO_WITH_OFFSET.exec(value);
5454
if (!match || !Number.isFinite(Date.parse(value))) return false;
5555
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
56-
return new Date(Date.UTC(year, month - 1, day)).getUTCDate() === day && month <= 12;
56+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
57+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
58+
return days !== undefined && day >= 1 && day <= days;
5759
}
5860

5961
// Checked by filter, not pattern, to keep the MCP tool schema small.

0 commit comments

Comments
 (0)