feat: add location and description fields to reminders

This commit is contained in:
2026-05-18 14:36:54 +02:00
parent 7be2dde131
commit e4a621d6a5
3 changed files with 69 additions and 7 deletions

View File

@@ -32,6 +32,8 @@ type rem = {
source : string; (** Source file or identifier for the reminder *)
original_uuid : string; (** Original UID from the iCalendar event *)
summary : string; (** Summary or title of the reminder *)
location : string option; (** Optional location of the event *)
description : string option; (** Optional description of the event *)
date : Timedesc.Date.t; (** Date specification (day, month, year) *)
end_date : Timedesc.Date.t option; (** Optional end date for a date range *)
time : Timedesc.Time.t option; (** Optional time specification (hour, minute) *)
@@ -54,6 +56,8 @@ let empty =
source = "";
original_uuid = "";
summary = "";
location = None;
description = None;
date = Timedesc.Date.Ymd.make_exn ~year:1970 ~month:1 ~day:1;
end_date = None;
time = None;
@@ -71,8 +75,8 @@ let empty =
(* ── buffer primitives ────────────────────────────────────────── *)
let add_rem b = Buffer.add_string b "REM "
let add_info b uuid = Buffer.add_string b (spf "INFO \"UID: %s\" " uuid)
let add_source b source = Buffer.add_string b (spf "INFO \"Calendar: %s\" " (String.uppercase_ascii source))
let add_uid b uuid = Buffer.add_string b (spf "\\\n INFO \"UID: %s\" " uuid)
let add_source b source = Buffer.add_string b (spf "\\\n INFO \"Calendar: %s\" " (String.uppercase_ascii source))
let add_date b date = Buffer.add_string b (Timedesc.Date.to_rfc3339 date)
let add_weekday b wd = Buffer.add_string b (spf "%s " (string_of_weekday wd))
@@ -164,6 +168,9 @@ let escape_msg s =
let buf = Buffer.create (String.length s) in
String.iter
(function
| '\n' -> Buffer.add_string buf "\\n"
| '\t' -> ()
| '"' -> Buffer.add_string buf "\\\""
| '%' -> Buffer.add_string buf "%%"
| '[' -> Buffer.add_string buf {|["["]|}
| c -> Buffer.add_char buf c)
@@ -172,6 +179,21 @@ let escape_msg s =
let add_msg b summary = Buffer.add_string b (spf " MSG %s\n" (escape_msg summary))
let add_location b loc =
match loc with
| Some loc -> begin
let loc = String.trim loc in
Buffer.add_string b (spf "\\\n INFO \"Location: %s\" " (escape_msg loc))
end
| None -> ()
let add_description b desc =
match desc with
| Some desc ->
let desc = String.trim desc in
Buffer.add_string b (spf "\\\n INFO \"Description: %s\" " (escape_msg desc))
| None -> ()
let date_of_date_or_datetime (d : Icalendar.date_or_datetime) : Timedesc.Date.t =
match d with
| `Date (year, month, day) -> Timedesc.Date.Ymd.make_exn ~year ~month ~day
@@ -199,8 +221,10 @@ let render_daily rem (d : simple_daily) =
let b = Buffer.create 256 in
add_omit_context b rem.exdate;
add_rem b;
add_info b rem.original_uuid;
add_uid b rem.original_uuid;
add_source b rem.source;
add_location b rem.location;
add_description b rem.description;
add_date b rem.date;
Buffer.add_char b ' ';
add_interval_daily b d;
@@ -218,8 +242,10 @@ let render_weekly rem (w : simple_weekly) =
List.iter
(fun wd ->
add_rem b;
add_info b rem.original_uuid;
add_uid b rem.original_uuid;
add_source b rem.source;
add_location b rem.location;
add_description b rem.description;
add_weekday b wd;
add_date b rem.date;
Buffer.add_char b ' ';
@@ -237,8 +263,10 @@ let render_monthly rem (m : simple_monthly) =
let b = Buffer.create 256 in
add_omit_context b rem.exdate;
add_rem b;
add_info b rem.original_uuid;
add_uid b rem.original_uuid;
add_source b rem.source;
add_location b rem.location;
add_description b rem.description;
(match m.pattern with
| By_month_day day -> Buffer.add_string b (spf "%d " day)
| By_nth_weekday (n, wd) when n > 0 ->
@@ -261,8 +289,10 @@ let render_monthly rem (m : simple_monthly) =
let render_single rem =
let b = Buffer.create 256 in
add_rem b;
add_info b rem.original_uuid;
add_uid b rem.original_uuid;
add_source b rem.source;
add_location b rem.location;
add_description b rem.description;
add_date b rem.date;
add_at b rem.time;
add_duration b rem.duration;
@@ -273,8 +303,10 @@ let render_single rem =
let render_yearly rem month day =
let b = Buffer.create 64 in
add_rem b;
add_info b rem.original_uuid;
add_uid b rem.original_uuid;
add_source b rem.source;
add_location b rem.location;
add_description b rem.description;
Buffer.add_string b (spf "%s %d" (month_of_int month |> string_of_month) day);
add_msg b rem.summary;
Buffer.contents b