Restore local-time reset clock on the reset readout#6
Merged
Conversation
The Python status line showed the absolute local time each window resets at (e.g. "resets in 6d3h @ 12am (Wed)"); the Rust port kept only the relative duration. Bring the clock back next to the duration on both the status line (53m @ 1:59pm (Thu)) and the report. Rust's std has no timezone support, so a new localtime module converts the UTC reset epoch to local hour/minute/weekday via the C library's reentrant localtime_r (unix) / _localtime64_s (Windows UCRT) — the same path Python's datetime.fromtimestamp uses under the hood. This is DST/zone-correct from the OS tz database, needs no external crate (binary stays ~430KB), and degrades to the bare duration if local time can't be resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Brings back the absolute local-time reset indicator that the Python status line had and the Rust port dropped. The reset readout now shows both the time-to-reset and the local clock it lands at, on the status line and in
report:How
Rust's standard library has no timezone support —
SystemTimeonly yields a UTC epoch and std can't resolve the local offset or DST. A newlocaltimemodule converts the UTC reset epoch to local hour/minute/weekday by calling the C library's reentrantlocaltime_r(unix) /_localtime64_s(Windows UCRT), which read the OS timezone database. This is the same mechanism Python'sdatetime.fromtimestampuses under the hood, so it's a faithful restore.fmt_clock_partsis a pure function with unit tests covering the midnight/noon/am-pm/weekday boundaries.Verification
cargo fmt --check,cargo clippy -D warnings,cargo testall pass (17 tests, incl. newclock_parts).1:05pm Thu, a 54-min 5h reset renders53m @ 1:59pm (Thu)and a 6d3h weekly reset renders@ 5:05pm (Wed)— both correct local times.tmlayout,time_twidth, symbol/arg order,MaybeUninitsoundness, reentrancy) — no soundness or correctness issues found.