[docs] [issue9063] TZ examples in datetime.rst are incorrect

Alexander Belopolsky report at bugs.python.org
Wed Jun 23 20:29:51 CEST 2010


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Let's establish what is the correct wall clock sequence around EDT to EST transition:

>>> import time
>>> def print_time(s):
...    tt = time.localtime(s)
...    print(time.strftime('%c %z %Z', tt))

x = datetime(2010, 11, 7, 5)
>>> s = (x - datetime(1970, 1, 1))//timedelta(seconds=1)

>>> for i in range(-3600, 5000, 1200):
...   print_time(s + i)
... 
Sun Nov  7 00:00:00 2010 -0400 EDT
Sun Nov  7 00:20:00 2010 -0400 EDT
Sun Nov  7 00:40:00 2010 -0400 EDT
Sun Nov  7 01:00:00 2010 -0400 EDT
Sun Nov  7 01:20:00 2010 -0400 EDT
Sun Nov  7 01:40:00 2010 -0400 EDT
Sun Nov  7 01:00:00 2010 -0500 EST
Sun Nov  7 01:20:00 2010 -0500 EST

However, neither Local nor Eastern tzinfo instance is capable of reproducing this sequence:


>>> for i in range(-3600, 5000, 1200):
...   print(datetime.fromtimestamp(s + i, Eastern).strftime('%c %z %Z'))

Sun Nov  7 00:00:00 2010 -0400 EDT
Sun Nov  7 00:20:00 2010 -0400 EDT
Sun Nov  7 00:40:00 2010 -0400 EDT
Sun Nov  7 01:00:00 2010 -0500 EST
Sun Nov  7 01:20:00 2010 -0500 EST
Sun Nov  7 01:40:00 2010 -0500 EST
Sun Nov  7 01:00:00 2010 -0500 EST
Sun Nov  7 01:20:00 2010 -0500 EST

>>> for i in range(-3600, 5000, 1200):
...   print(datetime.fromtimestamp(s + i, Local).strftime('%c %z %Z'))
 
Sun Nov  7 00:00:00 2010 -0400 EDT
Sun Nov  7 00:20:00 2010 -0400 EDT
Sun Nov  7 00:40:00 2010 -0400 EDT
Sun Nov  7 01:00:00 2010 -0400 EDT
Sun Nov  7 01:20:00 2010 -0400 EDT
Sun Nov  7 01:40:00 2010 -0400 EDT
Sun Nov  7 02:00:00 2010 -0500 EST
Sun Nov  7 02:20:00 2010 -0500 EST

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9063>
_______________________________________


More information about the docs mailing list