···
let get_start_timezone t =
match t.event.dtstart with
| _, `Datetime (`With_tzid (_, (_, tzid))) -> Some tzid
171
+
| _, `Datetime (`Utc _) -> Some "UTC"
172
+
| _, `Datetime (`Local _) -> Some "FLOATING"
match t.event.dtend_or_duration with
| Some (`Dtend (_, `Datetime (`With_tzid (_, (_, tzid))))) -> Some tzid
178
+
| Some (`Dtend (_, `Datetime (`Utc _))) -> Some "UTC"
179
+
| 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
393
+
let start_timezone = get_start_timezone event in
394
+
let end_timezone = get_end_timezone event in
395
+
let same_timezone =
396
+
match (start_timezone, end_timezone) with
397
+
| Some tz1, Some tz2 when tz1 = tz2 -> true
390
-
match is_date event with true -> "" | false -> " " ^ format_time ?tz start
401
+
match is_date event with
405
+
if same_timezone then " " ^ format_time ?tz start
407
+
match start_timezone with
408
+
| Some tzid -> " " ^ format_time ?tz start ^ " (" ^ tzid ^ ")"
409
+
| None -> " " ^ format_time ?tz start
···
| false -> (" - " ^ format_date ?tz end_, ""))
match day_diff start ~next:end_ == 0 with
403
-
| true -> ("", " - " ^ format_time ?tz end_)
404
-
| false -> (" - " ^ format_date ?tz end_, " " ^ format_time ?tz end_)
426
+
match end_timezone with
427
+
| Some tzid when same_timezone ->
428
+
("", " - " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")")
430
+
("", " - " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")")
431
+
| None -> ("", " - " ^ format_time ?tz end_)
436
+
match end_timezone with
437
+
| Some tzid when same_timezone ->
438
+
( " - " ^ format_date ?tz end_,
439
+
" " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")" )
441
+
( " - " ^ format_date ?tz end_,
442
+
" " ^ format_time ?tz end_ ^ " (" ^ tzid ^ ")" )
444
+
(" - " ^ 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:""
436
-
let format timezone datetime =
477
+
let start_timezone = get_start_timezone event in
478
+
let end_timezone = get_end_timezone event in
479
+
let same_timezone =
480
+
match (start_timezone, end_timezone) with
481
+
| Some tz1, Some tz2 when tz1 = tz2 -> true
484
+
let format timezone datetime is_end =
| true -> format_date ?tz datetime
440
-
format_datetime ?tz datetime
441
-
^ match timezone with None -> "" | Some t -> " (" ^ t ^ ")")
489
+
if (not is_end) && same_timezone then ""
490
+
else match timezone with None -> "" | Some t -> " (" ^ t ^ ")"
492
+
format_datetime ?tz datetime ^ tz_suffix
444
-
format_opt "Start" (format (get_start_timezone event)) (Some start)
495
+
format_opt "Start" (fun d -> format start_timezone d false) (Some start)
446
-
let end_str = format_opt "End" (format (get_end_timezone event)) end_ in
498
+
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)