[Datetime-SIG] PEP 495 and the hardest problem in computer science

Random832 random832 at fastmail.com
Wed Jun 29 14:35:36 EDT 2016


On Wed, Jun 29, 2016, at 14:19, Alexander Belopolsky wrote:
> I don't think you are correct.  With the current Github implementation
> [1]
> of the PEP, I can do the following:
> 
> >>> from datetime import *
> >>> from test.datetimetester import ZoneInfo
> >>> London = ZoneInfo.fromname('Europe/London')
> >>> t0 = datetime(2016, 11, 6, 1, 30, fold=0)
> >>> t1 = datetime(2016, 11, 6, 1, 30, fold=1)
> >>> print(t0.astimezone(London))
> 2016-11-06 05:30:00+00:00
> >>> print(t1.astimezone(London))
> 2016-11-06 06:30:00+00:00
> 
> In the snippet above, t0 and t1 are "naive times that care about the
> 'fold'."  (My system TZ is US/Eastern.)  I am not sure what you mean by
> being portable, but I can convert either of those times to London Time
> using .astimezone() which assumes local timezone for naive instances.

Er, I was talking about using it as a naive time using the london
timezone. Basically, the opposite of what you did: converting that naive
time _from_ London time (you should be able to convert it from any
timezone, after all, since it's naive) _to_ some other timezone.


More information about the Datetime-SIG mailing list