Re: "zoning" a naive datetime object / daylight savings
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: "zoning" a naive datetime object / daylight savings

From: Adam Monsen <haircut@gmail.com>
Date: Thu Sep 01 2005 - 05:53:02 CEST

Ok, I think I figured this out. Comments/criticisms welcome.

----------------------------------8<----------------------------------
import datetime, os, time
from pytz import UTC
old_tz = os.environ.get('TZ')
os.environ['TZ'] = 'Europe/Amsterdam'
time.tzset()
dutchDateParts = (2005, 8, 10, 17, 26, 0, 2, 222, -1)
timestamp = time.mktime(dutchDateParts)
if old_tz: os.environ['TZ'] = old_tz
else: del os.environ['TZ']
time.tzset()
print datetime.datetime.fromtimestamp(timestamp, UTC)
---------------------------------->8----------------------------------

The 9-integer time tuple could be fetched using the code posted here:
http://snipurl.com/hcvs
same URL, not snipped:
http://groups.google.com/group/comp.lang.python/msg/65d8f116dfd59dd1

--
Adam Monsen
http://adammonsen.com/
Received on Thu Sep 29 18:11:50 2005