datetime and tzinfo
jdhunter at ace.bsd.uchicago.edu
Thu Sep 16 15:42:08 CEST 2004
I am using the tzinfo classes from the datetime docs, eg UTC,
USTimeZone, and the instantiations Pacific, Central, Eastern, etc. I
would like to take a datetime instance in the UTC timezone and
construct the equivalent in another time zone.
Eg, if I am given dt1 in the example below, and the timezone Central
dt1 = datetime(2004, 9, 12, 14, 22, 24, tzinfo=UTC())
I would like to construct the datetime instance dt2
dt2 = datetime(2004, 9, 12, 9, 22, 24, tzinfo=Central)
which is the same time in a different timezone.
>>> dt1 = datetime(2004, 9, 12, 14, 22, 24, tzinfo=UTC())
>>> dt2 = datetime(2004, 9, 12, 9, 22, 24, tzinfo=Central)
I've read through the docs at
http://www.python.org/doc/2.3.2/lib/datetime-tzinfo.html but none of
the methods looked just right.
Is there an easy/right way to do this?
More information about the Python-list