Skip to content

feat(time): project-wide locale + timezone consistency - #179

Merged
unhappychoice merged 1 commit into
mainfrom
feat/locale-timezone-consistency
Apr 28, 2026
Merged

unhappychoice merged 1 commit into
mainfrom
feat/locale-timezone-consistency

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #154. Pulls every fetcher / renderer that emits a human-readable timestamp through a shared crate::time helper module so the same [general].timezone / [general].locale defaults flow through every clock-shaped output instead of each call site reaching for Local::now() or Utc::now() independently.

  • New crate::time module with now_in(tz), today_in(tz), parse_tz, parse_locale, format_local(dt, fmt, locale), and format_relative_compact(seconds, locale).
  • Enables chrono's unstable-locales feature so %A / %B respect a configured locale.
  • Adds timezone and locale to [general] in settings; runtime threads them onto every FetchContext and RenderOptions (per-widget options can still override — clock_* keeps its own timezone knob, etc.).
  • Migrates clock_*, rss, todoist, list_timeline, plus git_{blame_heatmap,commits_activity,contributors,churn,latest_tag} off raw Local::now() / Utc::now() to the shared helpers.

Behaviour with tz = None and locale = None matches the previous output bit-for-bit (POSIX is what chrono's unlocalised format already emits), so existing configs render the same strings.

Test plan

  • cargo test --workspace (1117 passed)
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • Smoke-test with [general] timezone = "Asia/Tokyo" + locale = "ja_JP" and verify clock / rss / list_timeline pick up the localized output

Out of scope (follow-ups, captured in #154)

  • git/age.rs, wikipedia/*, calendar/holidays.rs and a few other call sites still use Utc::now() directly. Issue's affected-sites list was "scan, not exhaustive"; left for a follow-up so the diff stays focused on the listed sites.
  • Translations of widget labels / error messages — out of scope per the issue.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Summary by CodeRabbit

  • New Features
    • Timezone and locale settings are now configurable in the dashboard configuration. All timestamps and date/time displays throughout dashboard widgets now respect your configured timezone (using IANA timezone names) and locale preferences, ensuring accurate time representation in any timezone with proper localization. The dashboard falls back to your system's local time and standard formatting when these settings are not explicitly configured.

Refs #154. Pulls every fetcher / renderer that emits a human-readable
timestamp through a shared `crate::time` helper module so the same
`[general].timezone` / `[general].locale` defaults flow through every
clock-shaped output instead of each call site reaching for `Local::now()`
or `Utc::now()` independently.

- Adds `crate::time::{now_in, today_in, parse_tz, parse_locale,
  format_local, format_relative_compact}` and enables chrono's
  `unstable-locales` feature so localized month / weekday names work.
- Adds `[general].timezone` (IANA name) and `[general].locale` (chrono
  locale code) to settings; runtime threads them onto every
  `FetchContext` and `RenderOptions` (per-widget overrides still win).
- Migrates clock_*, rss, todoist, list_timeline, plus
  git_{blame_heatmap,commits_activity,contributors,churn,latest_tag}
  off raw `Local::now()` / `Utc::now()` to the shared helpers.

Behaviour with `tz = None` and `locale = None` matches the previous
output bit-for-bit (POSIX is what chrono's unlocalised `format` already
emits).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR implements project-wide timezone and locale consistency by introducing a centralized time module with shared helpers for timezone-aware formatting and relative time rendering. The [general] configuration gains timezone and locale fields, which are threaded through fetcher and rendering pipelines to replace inconsistent Local::now() and UTC-only formatting with a unified, configurable approach.

Changes

Cohort / File(s) Summary
Configuration & Core Utilities
Cargo.toml, src/lib.rs, src/config.rs, src/time.rs
Adds unstable-locales feature to chrono, exports new time module, extends [general] config with optional timezone and locale fields, introduces comprehensive timezone and locale helper functions including now_in, parse_locale, format_local, and format_relative_compact.
Fetcher Context & Infrastructure
src/fetcher/mod.rs
Adds timezone and locale fields to FetchContext struct to carry general configuration into fetcher execution.
Clock Fetcher Family
src/fetcher/clock/common.rs, src/fetcher/clock/mod.rs, src/fetcher/clock/timezones.rs
Refactors timezone and formatting to delegate to crate::time helpers, introduces safe_format_with_locale function, threads locale through formatting paths for all configured timezones.
Git Fetchers
src/fetcher/git/blame_heatmap.rs, src/fetcher/git/churn.rs, src/fetcher/git/commits_activity.rs, src/fetcher/git/contributors.rs, src/fetcher/git/latest_tag.rs
Updates all git fetchers to use timezone-aware timestamp computation via t::now_in() instead of Local::now() or Utc::now(), threads timezone/locale through date bucketing and formatting operations.
Other Fetchers
src/fetcher/rss.rs, src/fetcher/todoist.rs
RSS: threads timezone and locale through rendering pipeline with locale-aware formatting. Todoist: switches from Local to FixedOffset and uses t::now_in() for timestamp computation.
Rendering & Layout Infrastructure
src/render/mod.rs, src/layout.rs, src/render/list_timeline.rs, src/render/test_utils.rs
Adds timezone and locale fields to RenderOptions, threads General configuration through layout/render pipeline, refactors list_timeline relative/absolute date formatting to use shared crate::time helpers with locale support.
Runtime & Preview
src/runtime.rs, src/install/preview.rs, examples/preview_template.rs, xtask/src/dashboard_snapshot.rs, xtask/src/snapshots.rs
Threads general configuration through runtime execution (fetch context construction, cache key computation, rendering), updates preview and snapshot generation to supply general config to layout and rendering engines.

Sequence Diagram

sequenceDiagram
    participant Config as Config Loader
    participant Runtime as Runtime
    participant Fetcher as Fetcher
    participant Time as time::<br/>Helpers
    participant Renderer as Renderer
    participant Layout as Layout Engine

    Config->>Runtime: Load [general]<br/>timezone, locale
    Runtime->>Runtime: Create FetchContext<br/>with tz/locale
    Runtime->>Fetcher: fetch(&ctx)
    Fetcher->>Time: now_in(ctx.timezone)
    Time-->>Fetcher: DateTime<FixedOffset>
    Fetcher->>Time: format_local(dt, fmt,<br/>ctx.locale)
    Time-->>Fetcher: formatted string
    Fetcher-->>Runtime: payload
    Runtime->>Renderer: render_payload(...,<br/>theme, general)
    Renderer->>Layout: draw(..., general,<br/>loading)
    Layout->>Renderer: (sub-widget rendering)
    Renderer->>Time: format_local(...,<br/>opts.locale)
    Time-->>Renderer: formatted string
    Renderer-->>Layout: rendered shape
    Layout-->>Runtime: output
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 Hops through timezones with glee,
Locale-aware as can be,
Config now rules the day,
No more UTC's strict way,
Timestamps bloom wild and free! 🌍✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main feature: adding project-wide locale and timezone consistency through a shared time module and general configuration.
Linked Issues check ✅ Passed The PR fully implements objectives from #154: shared time module with now_in/parse_locale/format_local/format_relative_compact, [general] config with timezone/locale, FetchContext/RenderOptions threading, and migration of affected fetchers (rss, todoist, git variants, clock, list_timeline).
Out of Scope Changes check ✅ Passed All changes are scoped to #154 objectives: time module creation, config additions, threaded context/options, and fetcher migrations. No unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 89.05% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/locale-timezone-consistency

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.37644% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.22%. Comparing base (b9aa87c) to head (01a3a1e).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/runtime.rs 72.58% 34 Missing ⚠️
src/render/list_timeline.rs 89.58% 5 Missing ⚠️
src/fetcher/git/latest_tag.rs 91.30% 2 Missing ⚠️
src/fetcher/rss.rs 93.10% 2 Missing ⚠️
src/fetcher/todoist.rs 60.00% 2 Missing ⚠️
src/fetcher/clock/common.rs 91.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #179      +/-   ##
==========================================
+ Coverage   79.13%   79.22%   +0.08%     
==========================================
  Files         138      139       +1     
  Lines       27965    28258     +293     
==========================================
+ Hits        22131    22386     +255     
- Misses       5834     5872      +38     
Files with missing lines Coverage Δ
src/config.rs 87.16% <ø> (ø)
src/fetcher/clock/mod.rs 89.03% <100.00%> (+0.14%) ⬆️
src/fetcher/clock/timezones.rs 86.23% <100.00%> (+0.80%) ⬆️
src/fetcher/git/blame_heatmap.rs 85.57% <100.00%> (+0.83%) ⬆️
src/fetcher/git/churn.rs 82.70% <100.00%> (+0.29%) ⬆️
src/fetcher/git/commits_activity.rs 86.48% <100.00%> (+0.37%) ⬆️
src/fetcher/git/contributors.rs 77.84% <100.00%> (+0.54%) ⬆️
src/fetcher/mod.rs 84.97% <ø> (ø)
src/install/preview.rs 73.75% <100.00%> (+0.11%) ⬆️
src/layout.rs 93.65% <100.00%> (+0.29%) ⬆️
... and 8 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unhappychoice
unhappychoice merged commit a8450c3 into main Apr 28, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/locale-timezone-consistency branch April 28, 2026 03:12
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.

meta: project-wide locale & timezone consistency

1 participant