summaryrefslogtreecommitdiff
path: root/src/isodate/isotzinfo.py
diff options
context:
space:
mode:
authorGerhard Weis <gerhard.weis@gmx.com>2012-01-26 18:13:50 +1000
committerGerhard Weis <gerhard.weis@gmx.com>2012-01-26 18:13:50 +1000
commitca5daae1f2a1bd320dfbcaf30e08284b71ea15f9 (patch)
tree0336f9822f6c019cad5375f838015b01fc65bf1c /src/isodate/isotzinfo.py
parentff92360e320355651bbbc72dc79d3b0c306cd0f9 (diff)
downloadisodate-ca5daae1f2a1bd320dfbcaf30e08284b71ea15f9.tar.gz
tz_isoformat needs datetime object to determine daylight saving
never pass None into tzinfo.utcoffset (doesn't make sense; it's not deterministic)
Diffstat (limited to 'src/isodate/isotzinfo.py')
-rw-r--r--src/isodate/isotzinfo.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/isodate/isotzinfo.py b/src/isodate/isotzinfo.py
index 79797fa..df01384 100644
--- a/src/isodate/isotzinfo.py
+++ b/src/isodate/isotzinfo.py
@@ -74,7 +74,7 @@ def parse_tzinfo(tzstring):
int(groups['tzmin'] or 0))
raise ISO8601Error('%s not a valid time zone info' % tzstring)
-def tz_isoformat(tzinfo, format='%Z'):
+def tz_isoformat(dt, format='%Z'):
'''
return time zone offset ISO 8601 formatted.
The various ISO formats can be chosen with the format parameter.
@@ -87,11 +87,12 @@ def tz_isoformat(tzinfo, format='%Z'):
%z ... +-HHMM
%Z ... +-HH:MM
'''
- if (tzinfo is None) or (tzinfo.utcoffset(None) is None):
+ tzinfo = dt.tzinfo
+ if (tzinfo is None) or (tzinfo.utcoffset(dt) is None):
return ''
- if tzinfo.utcoffset(None) == ZERO and tzinfo.dst(None) == ZERO:
+ if tzinfo.utcoffset(dt) == ZERO and tzinfo.dst(dt) == ZERO:
return 'Z'
- tdelta = tzinfo.utcoffset(None)
+ tdelta = tzinfo.utcoffset(dt)
seconds = tdelta.days * 24 * 60 * 60 + tdelta.seconds
sign = ((seconds < 0) and '-') or '+'
seconds = abs(seconds)