···
let get_start_timezone t =
match t.event.dtstart with
| _, `Datetime (`With_tzid (_, (_, tzid))) -> Some tzid
+
| _, `Datetime (`Utc _) -> Some "UTC"
+
| _, `Datetime (`Local _) -> Some "FLOATING"
match t.event.dtend_or_duration with
| Some (`Dtend (_, `Datetime (`With_tzid (_, (_, tzid))))) -> Some tzid
+
| Some (`Dtend (_, `Datetime (`Utc _))) -> Some "UTC"
+
| Some (`Dtend (_, `Datetime (`Local _))) -> Some "FLOATING"
···
let start = get_start event in
let end_ = get_end event in
let start_date = format_date ?tz start in
+
let start_timezone = get_start_timezone event in
+
let end_timezone = get_end_timezone event in
+
match (start_timezone, end_timezone) with
+
| Some tz1, Some tz2 when tz1 = tz2 -> true
+
match is_date event with
+
if same_timezone then " " ^ format_time ?tz start
+
match start_timezone with
+
| Some tzid -> " " ^ format_time ?tz start ^ " (" ^ tzid ^ ")"
+
| None -> " " ^ format_time ?tz start
···
| false -> (" - " ^ format_date ?tz end_, ""))
match day_diff start ~next:end_ == 0 with
+
match end_timezone with
+
| Some tzid when same_timezone ->
+
("", " - " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")")
+
("", " - " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")")
+
| None -> ("", " - " ^ format_time ?tz end_)
+
match end_timezone with
+
| Some tzid when same_timezone ->
+
( " - " ^ format_date ?tz end_,
+
" " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")" )
+
( " - " ^ format_date ?tz end_,
+
" " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")" )
+
(" - " ^ format_date ?tz end_, " " ^ format_time ?tz end_)
match get_summary event with
···
Option.map (fun x -> Printf.sprintf "%s: %s\n" label (f x)) opt
|> Option.value ~default:""
+
let start_timezone = get_start_timezone event in
+
let end_timezone = get_end_timezone event in
+
match (start_timezone, end_timezone) with
+
| Some tz1, Some tz2 when tz1 = tz2 -> true
+
let format timezone datetime is_end =
| true -> format_date ?tz datetime
+
if (not is_end) && same_timezone then ""
+
else match timezone with None -> "" | Some t -> " (" ^ t ^ ")"
+
format_datetime ?tz datetime ^ tz_suffix
+
format_opt "Start" (fun d -> format start_timezone d false) (Some start)
+
format_opt "End" (fun d -> format end_timezone d true) end_
let location_str = format_opt "Location" Fun.id (get_location event) in
format_opt "Description" Fun.id (get_description event)