I feel it is necessary to start a new post to go on the discussion about
timezone.
In my system : win7+ python3.4 .
related official material.
https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime
%z UTC offset in the form +HHMM or -HHMM (empty string if the the
object is naive). (empty), +0000, -0400, +1030 (6)
%Z Time zone name (empty string if the object is naive). (empty), UTC,
EST, CST
1.%z (lowercase)
import datetime
t1='Sat, 09 Aug 2014 07:36:46 -0700' # - is after backword
t2='Sat, 09 Aug 2014 07:36:46 +0700' #+ is before foreward
dt1=datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z")
dt2=datetime.datetime.strptime(t2,"%a, %d %b %Y %H:%M:%S %z")
dt1.astimezone(datetime.timezone.utc)
datetime.datetime(2014, 8, 9, 14, 36, 46, tzinfo=datetime.timezone.utc)
dt2.astimezone(datetime.timezone.utc)
datetime.datetime(2014, 8, 9, 0, 36, 46, tzinfo=datetime.timezone.utc)
%z is sovled by our community.
2.%Z (uppercase) Time zone name
problem 1:
There are 24 time zone in the world, does any time zone has the time
zone name such as EST,CST ?
Are there 24 time zone abbreviations in python ?what are other 22
except for EST ,CST ?
problem 2:
t3='Sat, 09 Aug 2014 07:36:46 EST'
dt3=datetime.datetime.strptime(t3,"%a, %d %b %Y %H:%M:%S %Z")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python34\lib\_strptime.py", line 500, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "D:\Python34\lib\_strptime.py", line 337, in _strptime
(data_string, format))
ValueError: time data 'Sat, 09 Aug 2014 07:36:46 EST' does not match
format '%a,
%d %b %Y %H:%M:%S %Z'
does %Z remain problem?is it a bug in python datetime module?
--
https://mail.python.org/mailman/listinfo/python-list