Expand description
tzselect-rs — a faithful Rust port of upstream tzselect.ksh (tzdb).
tzselect.ksh (Paul Eggert, public domain) is the interactive tzdb
timezone selector: it asks the user (via stderr/stdin) to identify a location
— by continent→country→region, by geographic coordinates (-c), by a
proleptic POSIX TZ string, or by current local time — and prints the chosen
TZ value to stdout. It reads iso3166.tab (country codes→names) and
zone1970.tab (the zone table), and uses several embedded POSIX-awk programs.
This crate ports that behaviour to native Rust (no shell, no awk; the
POSIX-TZ grammar is hand-parsed, so there are no runtime dependencies).
Like the upstream it shells out to date for the current-time displays.
§Claim boundary
tzselect-rs does not define timezone policy or choose a timezone for the
user. It ports the interactive selection behaviour of upstream
tzselect.ksh into Rust, using the same tzdb table surfaces, and verifies
representative prompt/output paths against the upstream shell oracle. It is
the user-selection layer of the Rust tzdb toolchain, beside zic-rs and the
producer/QA crates; it does not enter libc localtime/strftime runtime
territory.
§Parity contract
The deterministic oracle is LC_ALL=C.UTF-8 COLUMNS=1 tzselect (single-column
select, raw-UTF-8 names, bytewise sort). The two live-clock lines
(Selected time is now: / Universal Time is now:) and the interactive
time/now menus are time-dependent and classified as such. Wide-terminal
multi-column select layout and non-UTF-8-locale iconv transliteration are
shell/terminal/locale rendering details, also classified.
Structs§
- Options
- Parsed command-line / environment options.
Traits§
- Host
- Host services the port needs from the environment — abstracted so the
interactive driver is unit-testable and the
dateshell-out is injectable.
Functions§
- posix_
tz_ valid - Hand-parsed equivalent of the
check_POSIX_TZ_stringregex (no regex crate). - run
- Run the interactive selector. Returns the process exit code; the chosen
TZis delivered viaHost::out. - usage
- The usage text (
tzselect.ksh:54-76).