From 3e9d3b3437f2d63a47f9c962ba9187c5ef692328 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Wed, 30 Dec 2020 17:40:57 +0100 Subject: ics: print the timezone name in the ICS file Add the correct timezone in generated ICS files. The timezone is fetched from /etc/timezone. Even though this is not standard, if a tool needs it, it should be able to understand it correctly. Signed-off-by: Alban Gruin --- src/ics.ml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ics.ml') diff --git a/src/ics.ml b/src/ics.ml index 6dd747d..d1bb808 100644 --- a/src/ics.ml +++ b/src/ics.ml @@ -61,8 +61,19 @@ type t = Event.t list let make events = events -let to_string events = +let gen_vtimezone tz = + if tz <> "" then + ["BEGIN:VTIMEZONE"; + "TZID:" ^ tz; + "END:VTIMEZONE\n"] + |> List.map ics_split_line + |> String.concat "\n" + else + "" + +let to_string tz events = let date = current_date () in + let vtimezone = gen_vtimezone tz in let rec gen_events id str = function | [] -> str | event :: l -> @@ -70,5 +81,6 @@ let to_string events = "BEGIN:VCALENDAR\n\ VERSION:2.0\n\ PRODID:-//ucs//\n" + ^ vtimezone ^ gen_events 0 "" events ^ "END:VCALENDAR\n" -- cgit v1.2.1