T
Tino Lange
Hi!
I'm surprised about the following code, maybe you can give me a hint whether
that's bug or feature? I'm just trying to convert local time to GMT and one
method gives a strange result:
######################
_tz_germany)).astimezone(_tz_utc)
local.tzinfo)).astimezone(_tz_utc)
######################
Result:
--> Why is GMT (3) wrong?
Cheers,
Tino
I'm surprised about the following code, maybe you can give me a hint whether
that's bug or feature? I'm just trying to convert local time to GMT and one
method gives a strange result:
######################
datetime.time(local.hour, local.minute, local.second, local.microsecond,#! /usr/bin/env python
import datetime, pytz
_tz_utc = pytz.timezone("UTC")
_tz_germany = pytz.timezone("Europe/Berlin")
local = datetime.datetime.now(_tz_germany)
print "Local: ", local
gmt = local.astimezone(_tz_utc)
print "GMT (1)", gmt
gmt = datetime.datetime.combine(local.date(), local.timetz()).astimezone(_tz_utc)
print "GMT (2)", gmt
gmt = datetime.datetime.combine(datetime.date.today(),
_tz_germany)).astimezone(_tz_utc)
datetime.time(local.hour, local.minute, local.second, local.microsecond,print "GMT (3)", gmt
gmt = datetime.datetime.combine(datetime.date.today(),
local.tzinfo)).astimezone(_tz_utc)
local.tzinfo:", local.tzinfo, "(id: %s)" % id(local.tzinfo)print "GMT (4)", gmt
print "_tz_germany:", _tz_germany, "(id: %s)" % id(_tz_germany), ",
######################
Result:
(id: -1212868756)tlange@tinux:~/is.work/Scripts$ ./timeconv.py
Local: 2006-04-01 20:09:26.469445+02:00
GMT (1) 2006-04-01 18:09:26.469445+00:00
GMT (2) 2006-04-01 18:09:26.469445+00:00
GMT (3) 2006-04-01 19:09:26.469445+00:00
GMT (4) 2006-04-01 18:09:26.469445+00:00
_tz_germany: Europe/Berlin (id: -1212869684) , local.tzinfo: Europe/Berlin
--> Why is GMT (3) wrong?
Cheers,
Tino