fix: correct month/day swap in schedule time calculation
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 41s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 41s
The en-US Intl format is MM/DD/YYYY but the regex parsing was assigning capture group 1 (month) to day and capture group 2 (day) to month. For day 26+ this created an invalid month value (26), causing RangeError: Invalid time value when formatting the date. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -62,8 +62,8 @@ export function calculateNextRun(params: ScheduleParams): Date | null {
|
||||
const todayParts = todayStr.match(/(\d{2})\/(\d{2})\/(\d{4}), (\d{2}):(\d{2}):(\d{2})/)
|
||||
if (!todayParts) return new Date(now.getTime() + 24 * 60 * 60 * 1000)
|
||||
|
||||
const todayDay = parseInt(todayParts[1])
|
||||
const todayMonth = parseInt(todayParts[2]) - 1
|
||||
const todayMonth = parseInt(todayParts[1]) - 1
|
||||
const todayDay = parseInt(todayParts[2])
|
||||
const todayYear = parseInt(todayParts[3])
|
||||
|
||||
const target = makeDateInTZ(todayYear, todayMonth, todayDay, hours, minutes)
|
||||
@@ -74,7 +74,7 @@ export function calculateNextRun(params: ScheduleParams): Date | null {
|
||||
const tmStr = fmt(tomorrow)
|
||||
const tmParts = tmStr.match(/(\d{2})\/(\d{2})\/(\d{4}),/)
|
||||
if (!tmParts) return new Date(now.getTime() + 24 * 60 * 60 * 1000)
|
||||
return makeDateInTZ(parseInt(tmParts[3]), parseInt(tmParts[2]) - 1, parseInt(tmParts[1]), hours, minutes)
|
||||
return makeDateInTZ(parseInt(tmParts[3]), parseInt(tmParts[1]) - 1, parseInt(tmParts[2]), hours, minutes)
|
||||
}
|
||||
|
||||
if (frequency === 'weekly') {
|
||||
@@ -90,8 +90,8 @@ export function calculateNextRun(params: ScheduleParams): Date | null {
|
||||
const parts = candidateStr.match(/(\d{2})\/(\d{2})\/(\d{4}),/)
|
||||
if (!parts) continue
|
||||
|
||||
const candidateDay = parseInt(parts[1])
|
||||
const candidateMonth = parseInt(parts[2]) - 1
|
||||
const candidateMonth = parseInt(parts[1]) - 1
|
||||
const candidateDay = parseInt(parts[2])
|
||||
const candidateYear = parseInt(parts[3])
|
||||
|
||||
// Get day of week in the user's timezone
|
||||
|
||||
Reference in New Issue
Block a user