From 253d72221b0df0188345935b70bb1389cf28f3af Mon Sep 17 00:00:00 2001 From: Skkeye Date: Fri, 25 Sep 2026 00:25:36 -0400 Subject: [PATCH] Mark times on the day before a work day as -1 A time on the day after its work day shows "+1" (a night shift ending at 04:10 +1). A time on the day before, which a start backdated across midnight can produce, showed "+-1". It now shows "-1", on the Days screen and in Markdown reports. Co-Authored-By: Claude Opus 5.5 --- src/export/markdown.rs | 5 +++-- src/ui/component.rs | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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)), } }