Skip to content

feat(pick): show message times on the viewer's clock, not UTC - #55

Merged
backnotprop merged 1 commit into
plannotator:mainfrom
Triyambak-CA:feat/picker-local-time
Sep 1, 2026
Merged

feat(pick): show message times on the viewer's clock, not UTC#55
backnotprop merged 1 commit into
plannotator:mainfrom
Triyambak-CA:feat/picker-local-time

Conversation

@Triyambak-CA

Copy link
Copy Markdown
Contributor

The itch

The picker slices HH:MM straight out of the RFC 3339 stamp, so a transcript written in UTC is displayed in UTC with no zone marker. I am at +05:30, so every row reads five and a half hours in the past.

That is not just cosmetic, because the row shows a clock face and no date. A 19:53 from 27 July is indistinguishable from one from this evening. It cost me real time twice while debugging #53: I read a stale session as a live one, and chased the wrong explanation for several minutes before checking the transcript directly.

What changed

clock now moves the time to the machine's UTC offset.

Only a Z stamp is moved. One that already carries an offset (…+05:30) is local to whoever wrote it and is shown as written, so hosts that record local time are unaffected.

No date arithmetic is involved: crossing midnight changes the date, not the clock face, so this is (hh * 60 + mm + offset).rem_euclid(1440) and nothing more.

Where the offset comes from

std has no local-time API, and this crate deliberately carries no date dependency, so the offset comes from date +%z - the same shell-out idiom last::locate already uses - resolved once behind a OnceLock. Non-unix returns 0, and anything unparseable returns 0, so both keep exactly today's UTC behaviour rather than guessing.

If you would rather own a dependency for this, say so and I will switch it to jiff or time. I picked the zero-dependency version because of the note in Cargo.toml about keeping the build pure Rust, but it is your call and the change is small either way.

One existing test touched

the_picker_lists_newest_first_and_opens_the_chosen_message asserts on rendered times, which would otherwise vary by the machine running CI. The offset is held on App so that test pins it to 0 in one line and the assertions stay exactly as they were.

Tests

Three, in a tests module beside the code in pick.rs:

  • a_utc_stamp_is_shown_on_the_local_clock - including a day rollover, 19:53Z at +05:30 is 01:23
  • a_stamp_that_already_carries_an_offset_is_shown_as_written
  • a_zone_string_reads_as_minutes_east_of_utc

cargo fmt --all --check, cargo clippy --workspace --all-targets and cargo test --workspace all clean on 1.97.1.

Deliberately not included

Showing a date for messages that are not from today. That needs real civil-date arithmetic, which is where a dependency genuinely starts to earn its place, and it would double the size of this diff. Happy to follow up if you want it.

The picker sliced HH:MM straight out of the RFC 3339 stamp, so a transcript
written in UTC was displayed in UTC with no zone marker. At +05:30 that reads
five and a half hours in the past, and since the row shows a clock face and no
date, a message from last month looks like one from this evening. It cost me
real time twice before I noticed.

Times now move to the machine's offset. Only a `Z` stamp is moved; one that
already carries an offset is local to whoever wrote it and is shown as written.
No date arithmetic is involved, because crossing midnight changes the date, not
the clock face.

std has no local-time API and this crate deliberately carries no date
dependency, so the offset comes from `date +%z`, the same shell-out last::locate
already uses, resolved once. Non-unix and anything unparseable stay on UTC,
which is the behaviour they have today.

The offset is held on App so the drawing test can pin it to 0 and the picker
renders identically on any machine.
@backnotprop
backnotprop added this pull request to the merge queue Sep 1, 2026
Merged via the queue into plannotator:main with commit 055505e Sep 1, 2026
2 checks passed
@backnotprop

Copy link
Copy Markdown
Contributor

Merged. The Z-only conversion guard, the zero-dependency offset with UTC fallback, and pinning the offset in tests made this an easy review. Ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants