tasks: add "every N weeks/months/days/years" recurrence (KC-70)
Recurrence previously only supported 5 fixed rules with no interval. Adds TaskItem.recurrenceInterval (optional, nil = 1, so every existing task is unaffected), a stepper in the shared create/edit sheet, quick-add NLP for phrases like "every 2 weeks"/"biweekly"/"fortnightly", and threads the interval through both countdown widgets so their progress bars size correctly for biweekly/etc tasks too. Built on KC-69's consolidated RecurrenceRule engine. Verified two things by actually compiling and running standalone swiftc drivers rather than just reading: the core interval math (44/44, unchanged from KC-69) and the new quick-add regex patterns against realistic phrases including "look into tru housing options every two weeks" (11/11 passing). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -89,4 +89,21 @@ enum RecurrenceRule {
|
||||
guard let prev = cal.date(byAdding: comp, value: -step, to: next) else { return nil }
|
||||
return (prev, next)
|
||||
}
|
||||
|
||||
/// User-facing recurrence text — "Weekly" at interval 1 (unchanged from
|
||||
/// before intervals existed), "Every 2 Weeks" once N > 1. One shared
|
||||
/// formatter so the main app and the create/edit picker UI can't drift.
|
||||
static func displayLabel(label: String, interval: Int = 1) -> String {
|
||||
let n = max(1, interval)
|
||||
guard n > 1, label != "Every Weekday" else { return label }
|
||||
let unit: String
|
||||
switch label {
|
||||
case "Daily": unit = "Days"
|
||||
case "Weekly": unit = "Weeks"
|
||||
case "Monthly": unit = "Months"
|
||||
case "Yearly": unit = "Years"
|
||||
default: return label
|
||||
}
|
||||
return "Every \(n) \(unit)"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user