[Datetime-SIG] Are there any "correct" implementations of tzinfo?

Tim Peters tim.peters at gmail.com
Mon Sep 14 02:13:19 CEST 2015


[Guido]
> Wouldn't it be sufficient for people in Creighton to set their timezone to
> US/Central? IIUC the Canadian DST rules are the same as the US ones. Now,
> the question may remain how do people know what to set their timezone to.
> But neither pytz nor datetime can help with that -- it is up to the
> sysadmin.

As Laura's use case evolved, it seems it was more that a train
traveler from Halifax to Creighton wants to tell their Halifax
relatives when they'll arrive in Creighton, but (of course) expressed
in Halifax time.  Nobody in this case knows anything about Creighton's
rules, except the traveler may be staring at a train schedule giving
arrival in Creighton time anyway.

While this may be beyond pytz's wizardy, nothing is too hard for datetime ;-)

    datetime.timezone.setcontext("datetime-sig messages from mid-Sep 2015")
    arrivaltime = datetime.strptime(scraped_arrival_time, "<magic>")
    arrivaltime = datetime.replace(arrivaltime,
tzinfo=gettz("Context/Creighton"))
    print(arrivaltime.astimezone(gettz("Context/Halifax"))


More information about the Datetime-SIG mailing list