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