From bbad583e539d3304381d70ac4efdbd7c22be0130 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Tue, 14 Jul 2026 11:15:50 -0400 Subject: [PATCH] fix: correct day-of-month recurrence parsing to use monthly interval and set next due date --- src/views/components/AddTaskModal.jsx | 2 ++ src/views/components/CustomParsers.js | 35 ++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/views/components/AddTaskModal.jsx b/src/views/components/AddTaskModal.jsx index 8f5a08d..6d1b506 100644 --- a/src/views/components/AddTaskModal.jsx +++ b/src/views/components/AddTaskModal.jsx @@ -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 diff --git a/src/views/components/CustomParsers.js b/src/views/components/CustomParsers.js index 8e5cb4e..df9a5d1 100644 --- a/src/views/components/CustomParsers.js +++ b/src/views/components/CustomParsers.js @@ -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,