title: Python datetime subtracting date oddity
body: <p>I have a datetime object created from which I subtract 13 days as follow:</p>
  
  <pre><code>(date.today()-timedelta(days=13)).strftime('%Y-%m-%d')
  </code></pre>
  
  <p>The strangeness occurs when I execute the code at 6AM and 8:30AM. At 6AM, the resulting string is returned as (if today is 2012-02-29):</p>
  
  <p>2012-02-15</p>
  
  <p>which is 14 days before the current! However, running the same line at 8:30AM, the resulting string is returned as:</p>
  
  <p>2012-02-16</p>
  
  <p>Which then correct. So far I have not been able to figure out what the difference is between the small period of time. I use timezone naive datetime objects, if that is important. I would like to know what could cause this change in the resulting string date.</p>
  
  <p>Many thanks.</p>
  
  <p><strong>EDIT: (based on eumiro's suggestion below)</strong></p>
  
  <p>datetime.datetime.now() returns: </p>
  
  <pre><code>&gt;&gt;&gt; datetime.datetime(2012, 2, 29, 10, 46, 20, 659862) 
  </code></pre>
  
  <p>And the timezone is Europe/Vienna on the server and in the django application that runs the line of code. </p>
  
  <p>I also tried running a similar line to the one you suggested:</p>
  
  <pre><code>(pytz.timezone(settings.TIME_ZONE).localize(datetime.now(), is_dst=True) - \
      timedelta(days=13)).strftime('%Y-%m-%d') 
  </code></pre>
  
  <p>But with the same results... which is why I think I don't think it has much to do with timezones also. But at the same time not sure where else to look.</p>