How to add weekly timedeltas with regards to daylight saving timezones
I use this simple code without the need for other libraries:
from datetime import datetime, timedelta
from pytz import timezone
tz = timezone('Europe/Berlin')
dt = tz.localize(datetime(2014, 3, 27, 12))
week_naive = datetime.combine(dt.date() + timedelta(days=7), dt.time())
week_local = dt.tzinfo.localize(week_naive)
print(dt, "Original datetime")
print(week_local, "Next week datetime")
Outputs:
2014-03-27 12:00:00+01:00 Original datetime
2014-04-03 12:00:00+02:00 Next week datetime
timedelta(days=7)
means 7 days, as in 7*24
hours - not "solar days".
If you add 7 days to a timezone-aware datetime, you'll obtain a datetime that is 7 days later - independently of how that datetime is represented in the timezone.
It seems what you really want is to apply the delta to the time you specified, ignoring timezone details. Notice the difference:
In [13]: print my_tz.normalize( my_tz.localize( dt ) + delta )
2014-04-03 13:00:00+02:00
In [14]: print my_tz.normalize( my_tz.localize( dt + delta ) )
2014-04-03 12:00:00+02:00
So, if possible, apply the deltas to the datetimes before they are localized.