feat(monthly): add support for MONTHLY recurrence (P07, P08)
- Add `monthly_pattern`, `simple_monthly` types and `monthly` field to `rem` - Implement `render_monthly` and `add_until_monthly` in `remind.ml` - Handle `BYMONTHDAY` (P07) and nth-weekday `BYDAY` (P08) patterns in `eventPredicates.ml` - Add `add_months` utility for date arithmetic - Mark P07 and P08 as implemented in documentation
This commit is contained in:
14
bin/utils.ml
14
bin/utils.ml
@@ -160,6 +160,20 @@ let get_rdates ev =
|
||||
Printf.eprintf "Found RDATE with periods: %d entries; UID: %s\n" (List.length periods) uid;
|
||||
[]
|
||||
|
||||
let add_months (date : Timedesc.Date.t) (n : int) : Timedesc.Date.t =
|
||||
let year = Timedesc.Date.year date in
|
||||
let month = Timedesc.Date.month date in
|
||||
let day = Timedesc.Date.day date in
|
||||
let total_months = (year * 12) + (month - 1) + n in
|
||||
let new_year = total_months / 12 in
|
||||
let new_month = (total_months mod 12) + 1 in
|
||||
let rec try_day d =
|
||||
match Timedesc.Date.Ymd.make ~year:new_year ~month:new_month ~day:d with
|
||||
| Ok date -> date
|
||||
| Error _ -> try_day (d - 1)
|
||||
in
|
||||
try_day day
|
||||
|
||||
let get_recurrence_id ev =
|
||||
List.find_map
|
||||
(fun prop ->
|
||||
|
||||
Reference in New Issue
Block a user