[Guido] >> Those pytz methods work for any (pytz) timezone -- astimezone() with a >> default argument only works for the local time zone.
{Alex] > That's what os.environ['TZ'] = zonename is for. The astimezone() method > works for every timezone installed on your system. Try it - you won't even > need to call time.tzset()! I tried it. It makes no difference to anything for me. I stay on Windows to remind people that millions of Python users don't see any of the horrid nonsense Linuxish systems force on poor users ;-) > ... > In any case, there are three approaches to designing a TZ database interface > in the datetime module: the "as intended" approach, the pytz approach and > the astimezone(zonename:str) approach. Portability rules out #3, unless Python bundles its own zoneinfo wrapping. pytk's approach has many attractions, like no need for `fold` and no breakage of anything, and blazing fast .utcoffset(). Except at least <datetime, timedelta> arithmetic would have to be patched to do a `normalize` variant by magic (to attach the now-appropriate fixed-offset tzinfo, but without changing the clock in the process). Alas, that would be a huge speed hit for classic arithmetic. So, as always, the original intent is the only one that makes sense in the end ;-) > ... > That's why I believe PEP 495 followed by the implementation > of fold-aware "as intended" tzinfos (either within stdlib or by third > parties) is the right approach. Me too - except I think acceptance of 495 should be contingent upon someone first completing a fully functional (if not releasable) fold-aware zoneinfo wrapping. Details have a way of surprising, and we should learn from the last time we released a tzinfo spec in the absence of any industrial-strength wrappings using it. -- https://mail.python.org/mailman/listinfo/python-list