Perhaps the pytz normalize method is what you are looking for:
import datetime as dt import pytz tz=pytz.timezone('Europe/London') t1 = dt.datetime(2012,10,28,0,30,0) t1=tz.localize(t1) t2 = dt.timedelta(hours=3) sumVal = t1 + t2
sumVal stays in BST:
print(repr(sumVal))
After normalization, sumVal is in GMT:
sumVal = tz.normalize(sumVal) print(repr(sumVal)) # datetime.datetime(2012, 10, 28, 2, 30, tzinfo=<DstTzInfo 'Europe/London' GMT0:00:00 STD>)
Note. For London, the DST transition occurs at 2012-10-28 02:00:00 .
unutbu
source share