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) { if (dueDateParsed.result) {
syncDueDateStates(dueDateParsed.result) syncDueDateStates(dueDateParsed.result)
dueDateHighlight = dueDateParsed.highlight[0] dueDateHighlight = dueDateParsed.highlight[0]
} else if (repeat.dueDate) {
syncDueDateStates(repeat.dueDate)
} }
// Create the cleaned sentence by sequentially applying all cleanups // 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': case 'day_of_the_month:every':
result.frequency = parseInt(match[1], 10) const dayOfMonth = parseInt(match[1], 10)
result.frequencyMetadata.months = ALL_MONTHS result.frequencyType = 'interval'
result.frequencyMetadata.unit = 'days' 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 { return {
result, result,
name: pattern.name name: pattern.name.replace('{day}', dayOfMonth),
.replace('{day}', result.frequency) dueDate: suggestedDueDate.toISOString(),
.replace('{months}', result.frequencyMetadata.months.join(', ')),
highlight: [ highlight: [
{ {
text: pattern.name, text: pattern.name,