todo: monthly repeats seeded on a short month no longer skip it
- Commit
66059d9601f1ac6e88754cda659c57d11b9db3bc- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 06:54 UTC (5 days ago)
- Parents
cf5b406
Recurrence.firstOnOrAfter seeds the due date when a repeat is set on a due-less task. Its Monthly branch compared the raw anchor day (today.day == dayOfMonth) while every sibling path clamps — nextMonthly, this function's Yearly branch (pinned by the Feb-29 test), and QuickAdd's monthDay. On the clamped last day the match failed, so the seed skipped the whole month: Monthly(1,31).firstOnOrAfter(2026-04-30) returned 2026-05-31 instead of April's clamped occurrence 2026-04-30; the same on Feb 28/29. Reachable when a monthly task pinned at BYMONTHDAY=31 by a clamped completion roll (or an import) has its due date cleared and the repeat re-applied on a short month's last day. The match test now clamps the anchor to the current month's length, consistent with the rest of the module. Three new tests pin the April/February clamps and that non-occurrence days still advance. Reminder projection, query views, DST conversion and import/export were audited and cleared. Verified: :todo:testDevUnitTest passes in full; lint errors are pre-existing on untouched files.
Diff
todo/src/main/java/com/vayunmathur/todo/domain/Recurrence.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/domain/Recurrence.kt b/todo/src/main/java/com/vayunmathur/todo/domain/Recurrence.ktindex 60e09ae9cc..f3810e99ee 100644--- a/todo/src/main/java/com/vayunmathur/todo/domain/Recurrence.kt+++ b/todo/src/main/java/com/vayunmathur/todo/domain/Recurrence.kt@@ -62,7 +62,11 @@ sealed interface Recurrence { is Monthly -> when (dayOfMonth) { null -> true LAST_DAY -> today.day == lengthOfMonth(LocalDate(today.year, today.month.number, 1))- else -> today.day == dayOfMonth+ // Clamped like nextMonthly/Yearly: a 29th-31st schedule lands+ // on a short month's last day, so that day is an occurrence.+ else -> today.day == dayOfMonth.coerceAtMost(+ lengthOfMonth(LocalDate(today.year, today.month.number, 1)),+ ) } is Yearly -> { val anchorMonth = month
todo/src/test/java/com/vayunmathur/todo/domain/RecurrenceFirstOnOrAfterClampTest.kt
diff --git a/todo/src/test/java/com/vayunmathur/todo/domain/RecurrenceFirstOnOrAfterClampTest.kt b/todo/src/test/java/com/vayunmathur/todo/domain/RecurrenceFirstOnOrAfterClampTest.ktnew file mode 100644index 0000000000..a00cab2848--- /dev/null+++ b/todo/src/test/java/com/vayunmathur/todo/domain/RecurrenceFirstOnOrAfterClampTest.kt@@ -0,0 +1,36 @@+package com.vayunmathur.todo.domain++import kotlinx.datetime.LocalDate+import kotlin.test.Test+import kotlin.test.assertEquals++class RecurrenceFirstOnOrAfterClampTest {+ private fun d(y: Int, m: Int, day: Int) = LocalDate(y, m, day)++ @Test+ fun `monthly 31st seeded on a clamped month-end starts that day, not next month`() {+ // April has 30 days: the clamped April occurrence is Apr 30 itself+ // (nextDate Jan 31 -> Feb 28 -> Mar 31 -> Apr 30), so seeding a+ // due-less monthly-31st task on Apr 30 must not skip to May 31.+ assertEquals(d(2026, 4, 30), Recurrence.Monthly(1, 31).firstOnOrAfter(d(2026, 4, 30)))+ assertEquals(d(2026, 4, 30), Recurrence.Monthly(1, 30).firstOnOrAfter(d(2026, 4, 30)))+ }++ @Test+ fun `monthly 29th-31st seeded on February's last day starts that day`() {+ // 2026 is not a leap year; 2028 is.+ assertEquals(d(2026, 2, 28), Recurrence.Monthly(1, 31).firstOnOrAfter(d(2026, 2, 28)))+ assertEquals(d(2026, 2, 28), Recurrence.Monthly(1, 30).firstOnOrAfter(d(2026, 2, 28)))+ assertEquals(d(2026, 2, 28), Recurrence.Monthly(1, 29).firstOnOrAfter(d(2026, 2, 28)))+ assertEquals(d(2028, 2, 29), Recurrence.Monthly(1, 31).firstOnOrAfter(d(2028, 2, 29)))+ assertEquals(d(2028, 2, 29), Recurrence.Monthly(1, 30).firstOnOrAfter(d(2028, 2, 29)))+ }++ @Test+ fun `monthly clamp seeding still advances from non-occurrence days`() {+ assertEquals(d(2026, 2, 28), Recurrence.Monthly(1, 31).firstOnOrAfter(d(2026, 2, 27)))+ assertEquals(d(2026, 3, 31), Recurrence.Monthly(1, 31).firstOnOrAfter(d(2026, 3, 1)))+ assertEquals(d(2026, 4, 15), Recurrence.Monthly(1, 15).firstOnOrAfter(d(2026, 3, 16)))+ assertEquals(d(2026, 3, 31), Recurrence.Monthly(1, Recurrence.LAST_DAY).firstOnOrAfter(d(2026, 3, 4)))+ }+}