aboutsummaryrefslogtreecommitdiff
path: root/src/ics.ml
diff options
context:
space:
mode:
authorAlban Gruin2020-12-30 17:40:57 +0100
committerAlban Gruin2020-12-30 17:40:57 +0100
commit3e9d3b3437f2d63a47f9c962ba9187c5ef692328 (patch)
tree8b1f5e122ac9caeff3f56849a516e7b10d788d80 /src/ics.ml
parent8dff924f4d598da653794e29fb9929017e161aa3 (diff)
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 <alban at pa1ch dot fr>
Diffstat (limited to 'src/ics.ml')
-rw-r--r--src/ics.ml14
1 files changed, 13 insertions, 1 deletions
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"