Repository navigation
Description
Problem
Date/time handling is currently inconsistent across the project. Different fetchers reach for whichever `chrono` API was convenient, ending up with three different conventions in the same binary:
| convention | examples | issue |
|---|---|---|
| `Local::now()` / `Local` | `fetcher/todoist.rs`, `fetcher/git/blame_heatmap.rs`, `fetcher/git/contributors.rs` | uses host TZ, not configurable per-widget |
| `Utc::now()` / formatted in UTC | `fetcher/rss.rs` (`format_short` always UTC), `fetcher/git/contributors.rs::cutoff`, `fetcher/git/latest_tag.rs` | display dates jump by ±1 day for users not in UTC |
| `now_in(opts.timezone)` w/ `chrono_tz` opt | `clock_almanac` / `clock_sunrise` / `clock_countdown` (via `fetcher/clock/common.rs`) | the right model — config-driven IANA tz with `Local` fallback |
Locale is also unaddressed: `format("%b")` and `format("%A")` always produce English month/weekday names regardless of `LANG` / config. `chrono` requires the `unstable-locales` feature + a locale code; we don't pull it in.
Goal
Make TZ + locale a first-class, project-wide concern so every fetcher that emits a human-readable timestamp goes through the same path:
- A shared `time` helper module (likely promote `fetcher/clock/common.rs::now_in` into something like `crate::time`) with:
- `now_in(tz: Option<&str>) -> DateTime` — the `clock_*` family already has this.
- `format_local(dt, fmt, tz, locale) -> String` — wraps `chrono::format::DelayedFormat` with locale.
- `format_relative(seconds_ago, locale) -> String` — for `list_timeline`-style relative labels.
- Project-level config in `[general]`:
- `timezone = "Asia/Tokyo"` — IANA name, default `Local`.
- `locale = "en_US"` — chrono locale code, default `en_US`.
- Per-widget override — each fetcher that emits a date inherits `general` defaults but can override `timezone` / `locale` in its own options (mirror what `clock_*` already does).
- Migration: convert every existing `Local::now()` / hardcoded UTC formatter to the shared helper. Keep behaviour identical when no config is set (default = `Local` + `en_US`).
Affected sites (scan, not exhaustive)
```
src/fetcher/rss.rs::format_short # UTC "%b %d"
src/fetcher/todoist.rs # Local::now multiple call sites
src/fetcher/git/blame_heatmap.rs # Local::now().date_naive()
src/fetcher/git/contributors.rs # chrono::Utc::now() cutoff
src/fetcher/git/latest_tag.rs # "%Y-%m-%d" UTC formatter
src/fetcher/quote_of_day.rs # already uses Local — fine, but locale-blind
src/fetcher/clock/* (almanac/sunrise/countdown/ratio/state) # already TZ-aware, locale-blind
src/render/list_timeline.rs (relative labels) # "3h ago" — locale-blind
```
Out of scope
- Translations of widget labels, error messages, prompts. Locale here is only about how chrono renders dates/times.
- Number formatting (1,000 vs 1.000) — different L10N axis, address separately if it ever matters.
Notes
- `Cargo.toml` already has `chrono-tz` and `chrono` (without `unstable-locales`). Adding the locale feature is a single-line change.
- Surfaced while shipping feat(fetcher): add rss feed reader #153 (`rss` fetcher) — its `format_short` is UTC-only, which would mis-date posts for any non-UTC user. Treated as project-wide rather than rss-only.
🤖 Generated with Claude Code
Activity