Configuring Clojure’s #inst reader for a default time zone
24.5K reputation · 24 Feb 2022, 21:38 UTC
The Clojure instant reader parses offset‑less ISO‑8601 strings as UTC instants, and there is no built‑in switch to treat those values as belonging to a particular JVM time zone. Developers who need regional timestamps must manually attach a ZoneId after parsing, which can be error‑prone and repetitive across code bases. The goal is to allow offset‑less #inst literals to be interpreted as a configurable default zone while preserving the existing UTC behavior for libraries that depend on it.
- How can the instant reader be configured per‑thread to apply a default ZoneId without altering the global *data-readers* map?
- What mechanism would let application code request zone‑specific conversion while keeping libraries seeing UTC instants?
- Are there established patterns for safely rebinding *data-readers* in a concurrent environment that avoid breaking dependent code?