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 <[email protected]>
This commit is contained in:
skkeyeandClaude Opus 5.5 committed 2026-09-25 00:25:36 -04:00
1 parent ae9e1b1f08
commit 253d72221b
2 files changed
+7 -4

No files matched your search

+3 -2
View File
@@ -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)),
}
}
+4 -2
View File
@@ -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)),
}
}