diff --git a/src/export/markdown.rs b/src/export/markdown.rs index b6f2425..f677bab 100644 --- a/src/export/markdown.rs +++ b/src/export/markdown.rs @@ -80,12 +80,13 @@ pub fn render(report: &Report) -> String { lines.join("\n") + "\n" } -/// The end time, marked "(+1)" when it falls on the next calendar day. +/// The end time, marked "(+1)" when it falls on the next calendar day (or +/// "(-1)" the day before). fn out_time(report: &Report, day: &WorkDay, end: Timestamp) -> String { let days_later = report.local(end).date().duration_since(day.date()).as_hours() / 24; match days_later { 0 => report.time(end), - later => format!("{} (+{later})", report.time(end)), + later => format!("{} ({later:+})", report.time(end)), } } diff --git a/src/ui/component.rs b/src/ui/component.rs index 82b0940..642bd1a 100644 --- a/src/ui/component.rs +++ b/src/ui/component.rs @@ -92,12 +92,14 @@ impl Context<'_> { self.fmt.time(self.local(moment).time()) } - /// A clock time, marked "+1" when it falls the day after `day`. + /// A clock time, marked "+1" when it falls the day after `day` (or "-1" + /// the day before, which a backdated start can do). pub fn time_on(&self, moment: Timestamp, day: Date) -> String { let days_later = self.local(moment).date().duration_since(day).as_hours() / 24; match days_later { 0 => self.time(moment), - later => format!("{} +{later}", self.time(moment)), + // `:+` always writes the sign: +1, -1. + later => format!("{} {later:+}", self.time(moment)), } }