Can someone ( @pganssle ) tell me why I shouldn't do this:
ZoneInfo("/".join(readlink("/etc/localtime").split("/")[-2:]))
@glyph What are you trying to do here? You can use `ZoneInfo.from_file` to use the file directly if you know it exists.
That said, with proper error handling and fallbacks I don't see why doing that wouldn't work in a lot of situations. If you want something more robust I think `tzlocal` encapsulates a bunch of these kinds of hacks.
@pganssle to serialize and deserialize civil, aware datetimes in a way which is portable across multiple systems, I need a way to robustly identify the zone. Offsets are obviously inefficient due to DST, and I *want* to be responsive to tzdb updates for wall-clock accuracy for long-term future events. IANA identifiers seem to be the only game in town for this. But obviously users will often want to interpret input or current times according to their current local zone
@glyph Can you not ask the user what time zone they want to use?
@pganssle they already told the computer by setting the timezone, why am I bothering them by asking again?
@glyph Though I imagine that a general rule of "try to guess the time zone they care about by looking at `/etc/localtime` or the `TZ` variable or in the Windows registry or whatever" + have an option to manually specify your time zone would basically have you covered. You don't necessarily need a modal at the beginning like, "Hey, what is your time zone, I couldn't possibly figure this out."
@pganssle exactly. The use-case is a library which can be used to create things that are calendar-like, and I want the option for users to provide a useful default.
The real nightmare difficulty question here is “how to I provide a pleasant cross-platform command line experience for *selecting* a time zone without making the user learn about the zoneinfo database themselves”…