Expand description
Project-wide locale + timezone helpers. Every fetcher / renderer that emits a
human-readable timestamp goes through here so the same [general] defaults
(and per-widget overrides) drive every clock-shaped output instead of each
site reaching for Local::now() / Utc::now() independently.
now_in(tz)resolves an IANA name ("Asia/Tokyo") to a fixed-offsetDateTime. Falls back toLocalfor unknown names — never panics.today_in(tz)is the date-only counterpart for “today” math.parse_locale(name)resolves achrono::Localefrom"en_US"/"ja_JP". Falls back toPOSIX(chrono’s hard-coded English).format_local(dt, fmt, locale)ischrono::format_localizedwith a directive-error fallback so a typo’d%Qdoesn’t crash the splash.format_relative_compact(seconds, locale)is the3h/2d/1wrounding used bylist_timelineand friends. Locale only flips the suffix glyphs; the math is locale-independent.
Behaviour with tz = None and locale = None matches the pre-migration
Local::now() + format(...) output bit-for-bit (POSIX is what chrono’s
unlocalised format already emits), so call sites can migrate without
having to compare snapshots.
Constants§
Functions§
- format_
local - format_
relative_ compact 3h/2d/1wstyle label forseconds_ago. Future deltas grow aninprefix; sub-minute deltas collapse tonow. ReturnsNonewhen the delta exceeds ~4 weeks so callers can fall back to an absolute date.- now_in
- parse_
locale - parse_
tz - today_
in