fix: correct day-of-month recurrence parsing to use monthly interval and set next due date
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user