Time localized wrongly in Python
<p>Using python Im trying to localize a datetime value to timezone "America/Chicago" which is -06:00 currently.
I get the timezone the following way:</p>

<pre><code>&gt;&gt;&gt; import pytz
&gt;&gt;&gt; tz = pytz.timezone("America/Chicago")
&lt;DstTzInfo 'America/Chicago' CST-1 day, 18:00:00 STD&gt;
</code></pre>

<p>when I localize a date:</p>

<pre><code>&gt;&gt;&gt; my_date = tz.localize(datetime.now())
datetime.datetime(2016, 9, 24, 17, 4, 43, 439824, tzinfo=&lt;DstTzInfo 'America/Chicago' CDT-1 day, 19:00:00 DST&gt;)
</code></pre>

<p>Notice it is the wrong timezone after localize:</p>

<pre><code>&lt;DstTzInfo 'America/Chicago' CDT-1 day, 19:00:00 DST&gt;
</code></pre>

<p>And later when i ask for the offset, you can see it is confirmed it has the wrong offset:  </p>

<pre><code>&gt;&gt;&gt; my_date.strftime("%z")
'-0500'
</code></pre>

<p>Exactly the same happend if I use astimezone instead:</p>

<pre><code>&gt;&gt;&gt;my_date
datetime.datetime(2016, 9, 24, 22, 15, 1, 620364, tzinfo=&lt;UTC&gt;)

&gt;&gt;&gt;my_date.astimezone(tz)
datetime.datetime(2016, 9, 24, 17, 15, 1, 620364, tzinfo=&lt;DstTzInfo 'America/Chicago' CDT-1 day, 19:00:00 DST&gt;)
</code></pre>

<p>Btw Chicago is observing DST now. So -05.00 is the right offset. Pytz timezone by default has the standard time, but when localized can account for day light saving based on the date(as in your case).</p>

python python-2.7 datetime localization