Command-line and Emacs Calendar Client

fix next day calculations

Ryan Gibb c93e61a9 d7e8fd84

Changed files
+6 -11
lib
+6 -11
lib/event.ml
···
in
Printf.sprintf "%s %s%s" (format_date ?tz date) (format_time ?tz date) tz_str
-
let same_day day other =
-
let y1, m1, d1 = Ptime.to_date day in
-
let y2, m2, d2 = Ptime.to_date other in
-
y1 == y2 && m1 == m2 && d1 == d2
-
-
let next_day day ~next =
-
let y1, m1, d1 = Ptime.to_date day in
-
let y2, m2, d2 = Ptime.to_date next in
-
y1 == y2 && m1 == m2 && d1 == d2 - 1
+
let day_diff day ~next =
+
let span = Ptime.diff next day in
+
let d, _ = Ptime.Span.to_d_ps span in
+
d
(* exosed from icalendar *)
···
| Some end_ -> (
match is_date event with
| true -> (
-
match next_day start ~next:end_ with
+
match day_diff start ~next:end_ <= 1 with
| true -> ("", "")
| false -> (" - " ^ format_date ?tz end_, ""))
| false -> (
-
match same_day start end_ with
+
match day_diff start ~next:end_ == 0 with
| true -> ("", " - " ^ format_time ?tz end_)
| false -> (" - " ^ format_date ?tz end_, " " ^ format_time ?tz end_)
))