timezone
_timezone
¶
Detects the host's IANA timezone for propagation into containers.
Returned as a plain string ("Europe/Prague", "UTC", …) suitable
for use as a TZ env var inside the container — glibc resolves it
against /usr/share/zoneinfo without needing the host's filesystem.
detect_host_timezone()
¶
Return the host's IANA timezone name, or None if it can't be detected.
Tried in order:
$TZ— the user's explicit override./etc/timezone— Debian/Ubuntu convention, single-line zone name./etc/localtimesymlink — systemd-family hosts (and macOS) symlink this into the zoneinfo database; the zone name is the path suffix after thezoneinfo/component.
Returns None on hosts that expose none of the above (containers with
only a copied-in /etc/localtime file, for instance), letting the
caller fall back to the image default rather than guessing.