Problem working with localized timezones.

Issue #6 new
Hans Peter Hagblom
created an issue

I have a problem with that the offset gets wrong when working with timezones.

Below is a snippet that shows the problem, there is a date which is considered to be CEST and thus have an offset of 2 hours. When printing this I get the offset of 1 hour.

In [47]: tz_sthlm.localize(datetime.datetime.strptime('2017-05-01', '%Y-%m-%d')) Out[47]: datetime.datetime(2017, 5, 1, 0, 0, tzinfo=<DstTzInfo 'Europe/Stockholm' CEST+2:00:00 DST>)

In [48]: rfc3339.format(tz_sthlm.localize(datetime.datetime.strptime('2017-05-01', '%Y-%m-%d'))) Out[48]: '2017-05-01T00:00:00+01:00'

I looked into the code and found

rfc3339.py (row 79) return _timedelta_to_seconds(date.dst() or date.utcoffset())

Where the utc delta, is the value of the daylight savings adjustment and not the actual utc offset.

return _timedelta_to_seconds(date.utcoffset())

Might work better I think?

I might be able to supply a fix for this.

Comments (0)

  1. Log in to comment