Skip to content

Show local time on the dock clock instead of UTC - #325

Merged
iconidentify merged 1 commit into
iconidentify:mainfrom
tidux:fix/dock-clock-local-time
Oct 1, 2026
Merged

iconidentify merged 1 commit into
iconidentify:mainfrom
tidux:fix/dock-clock-local-time

Conversation

@tidux

@tidux tidux commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #324

Problem

The dock's clock tile showed UTC. wall_clock in dock/crates/chonk-dock/src/widgets/sampling.rs took the Unix epoch modulo 86,400, which is seconds since UTC midnight, and never applied a timezone. The chonk-dockclock reference dockapp copied the same logic.

Fix

  • Convert with libc::localtime_r, so TZ is honored, falling back to /etc/localtime.
  • Call 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's localtime_r doesn't recheck on its own. The libc crate doesn't bind tzset, so it is declared directly.
  • Truncate to the source's interval after converting, so zones with non-whole-hour offsets (e.g. +05:30) land on the right minute.
  • Apply the same change to dock/examples/chonk-dockclock, which adds a libc dependency there (already in the lockfile).

The Python and Go example clocks already used local time.

Testing

  • cargo build -p chonk-dock -p chonk-dockclock builds with no warnings; cargo test -p chonk-dock --lib passes (203 passed, 1 ignored).
  • A throwaway test printing wall_clock(1) agreed with date under the system zone (US/Pacific), TZ=UTC and TZ=Asia/Kolkata.

🤖 Generated with Claude Code

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>
@iconidentify
iconidentify merged commit 9beebae into iconidentify:main Oct 1, 2026
11 checks passed
@iconidentify iconidentify mentioned this pull request Oct 6, 2026
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.

chonk-dock is not reading the time zone

2 participants