Repository navigation
Show local time on the dock clock instead of UTC - #325
Merged
Merged
Conversation
The clock sampler took the Unix epoch modulo a day, which is seconds since UTC midnight; no timezone was ever applied. Convert with localtime_r so TZ, else /etc/localtime, is honored, and call tzset each time so a timezone changed while the dock is running shows up on the next tick. Truncation to the source's interval now happens after the conversion, so non-whole-hour offsets land on the right minute. The chonk-dockclock reference dockapp copied the same logic and gets the same fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Closes #324
Problem
The dock's clock tile showed UTC.
wall_clockindock/crates/chonk-dock/src/widgets/sampling.rstook the Unix epoch modulo 86,400, which is seconds since UTC midnight, and never applied a timezone. Thechonk-dockclockreference dockapp copied the same logic.Fix
libc::localtime_r, soTZis honored, falling back to/etc/localtime.tzset()before each conversion so a timezone changed while the dock is running (e.g.timedatectl set-timezone) takes effect on the next tick. glibc'slocaltime_rdoesn't recheck on its own. Thelibccrate doesn't bindtzset, so it is declared directly.dock/examples/chonk-dockclock, which adds alibcdependency there (already in the lockfile).The Python and Go example clocks already used local time.
Testing
cargo build -p chonk-dock -p chonk-dockclockbuilds with no warnings;cargo test -p chonk-dock --libpasses (203 passed, 1 ignored).wall_clock(1)agreed withdateunder the system zone (US/Pacific),TZ=UTCandTZ=Asia/Kolkata.🤖 Generated with Claude Code