Repository navigation
feat(time): project-wide locale + timezone consistency - #179
Conversation
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]>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR implements project-wide timezone and locale consistency by introducing a centralized Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
Summary
Closes #154. Pulls every fetcher / renderer that emits a human-readable timestamp through a shared
crate::timehelper module so the same[general].timezone/[general].localedefaults flow through every clock-shaped output instead of each call site reaching forLocal::now()orUtc::now()independently.crate::timemodule withnow_in(tz),today_in(tz),parse_tz,parse_locale,format_local(dt, fmt, locale), andformat_relative_compact(seconds, locale).unstable-localesfeature so%A/%Brespect a configured locale.timezoneandlocaleto[general]in settings; runtime threads them onto everyFetchContextandRenderOptions(per-widget options can still override — clock_* keeps its owntimezoneknob, etc.).clock_*,rss,todoist,list_timeline, plusgit_{blame_heatmap,commits_activity,contributors,churn,latest_tag}off rawLocal::now()/Utc::now()to the shared helpers.Behaviour with
tz = Noneandlocale = Nonematches the previous output bit-for-bit (POSIX is what chrono's unlocalisedformatalready emits), so existing configs render the same strings.Test plan
cargo test --workspace(1117 passed)cargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --check[general] timezone = "Asia/Tokyo"+locale = "ja_JP"and verifyclock/rss/list_timelinepick up the localized outputOut of scope (follow-ups, captured in #154)
git/age.rs,wikipedia/*,calendar/holidays.rsand a few other call sites still useUtc::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.🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Summary by CodeRabbit