fix: correct day-of-month recurrence parsing to use monthly interval and set next due date

This commit is contained in:
Mo Tarbin
2026-07-14 11:15:50 -04:00
parent 359202a594
commit bbad583e53
2 changed files with 31 additions and 6 deletions

View File

@@ -422,6 +422,8 @@ const TaskInput = ({ onChoreUpdate, isModalOpen, onClose }) => {
if (dueDateParsed.result) {
syncDueDateStates(dueDateParsed.result)
dueDateHighlight = dueDateParsed.highlight[0]
} else if (repeat.dueDate) {
syncDueDateStates(repeat.dueDate)
}
// Create the cleaned sentence by sequentially applying all cleanups

View File

@@ -412,14 +412,37 @@ export const parseRepeatV2 = inputSentence => {
}
case 'day_of_the_month:every':
result.frequency = parseInt(match[1], 10)
result.frequencyMetadata.months = ALL_MONTHS
result.frequencyMetadata.unit = 'days'
const dayOfMonth = parseInt(match[1], 10)
result.frequencyType = 'interval'
result.frequency = 1
result.frequencyMetadata.unit = 'months'
// Calculate the next occurrence of this day of the month
const todayEvery = new Date()
let suggestedDueDate = new Date(
todayEvery.getFullYear(),
todayEvery.getMonth(),
dayOfMonth,
23,
59,
0,
)
if (suggestedDueDate <= todayEvery) {
// Day has already passed this month, move to next month
suggestedDueDate = new Date(
todayEvery.getFullYear(),
todayEvery.getMonth() + 1,
dayOfMonth,
23,
59,
0,
)
}
return {
result,
name: pattern.name
.replace('{day}', result.frequency)
.replace('{months}', result.frequencyMetadata.months.join(', ')),
name: pattern.name.replace('{day}', dayOfMonth),
dueDate: suggestedDueDate.toISOString(),
highlight: [
{
text: pattern.name,