Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96536 > unrolled thread

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

Started byTim Peters <tim.peters@gmail.com>
First post2015-09-13 19:13 -0500
Last post2015-09-13 19:13 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo? Tim Peters <tim.peters@gmail.com> - 2015-09-13 19:13 -0500

#96536 — Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

FromTim Peters <tim.peters@gmail.com>
Date2015-09-13 19:13 -0500
SubjectRe: [Datetime-SIG] Are there any "correct" implementations of tzinfo?
Message-ID<mailman.507.1442189622.8327.python-list@python.org>
[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"))

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web