@@ -1203,14 +1203,14 @@ Using datetime with tzinfo:
12031203
12041204 >>> from datetime import timedelta, datetime, tzinfo
12051205 >>> class GMT1 (tzinfo ):
1206- ... def __init__ (self ): # DST starts last Sunday in March
1206+ ... def utcoffset (self , dt ):
1207+ ... return timedelta(hours = 1 ) + self .dst(dt)
1208+ ... def dst (self , dt ):
1209+ ... # DST starts last Sunday in March
12071210 ... d = datetime(dt.year, 4 , 1 ) # ends last Sunday in October
12081211 ... self .dston = d - timedelta(days = d.weekday() + 1 )
12091212 ... d = datetime(dt.year, 11 , 1 )
12101213 ... self .dstoff = d - timedelta(days = d.weekday() + 1 )
1211- ... def utcoffset (self , dt ):
1212- ... return timedelta(hours = 1 ) + self .dst(dt)
1213- ... def dst (self , dt ):
12141214 ... if self .dston <= dt.replace(tzinfo = None ) < self .dstoff:
12151215 ... return timedelta(hours = 1 )
12161216 ... else :
@@ -1219,16 +1219,15 @@ Using datetime with tzinfo:
12191219 ... return " GMT +1"
12201220 ...
12211221 >>> class GMT2 (tzinfo ):
1222- ... def __init__ (self ):
1222+ ... def utcoffset (self , dt ):
1223+ ... return timedelta(hours = 2 ) + self .dst(dt)
1224+ ... def dst (self , dt ):
12231225 ... d = datetime(dt.year, 4 , 1 )
12241226 ... self .dston = d - timedelta(days = d.weekday() + 1 )
12251227 ... d = datetime(dt.year, 11 , 1 )
12261228 ... self .dstoff = d - timedelta(days = d.weekday() + 1 )
1227- ... def utcoffset (self , dt ):
1228- ... return timedelta(hours = 1 ) + self .dst(dt)
1229- ... def dst (self , dt ):
12301229 ... if self .dston <= dt.replace(tzinfo = None ) < self .dstoff:
1231- ... return timedelta(hours = 2 )
1230+ ... return timedelta(hours = 1 )
12321231 ... else :
12331232 ... return timedelta(0 )
12341233 ... def tzname (self ,dt ):
@@ -1628,7 +1627,7 @@ When DST starts (the "start" line), the local wall clock leaps from 1:59 to
162816273:00. A wall time of the form 2:MM doesn't really make sense on that day, so
16291628``astimezone(Eastern) `` won't deliver a result with ``hour == 2 `` on the day DST
16301629begins. In order for :meth: `astimezone ` to make this guarantee, the
1631- :meth: `rzinfo .dst ` method must consider times in the "missing hour" (2:MM for
1630+ :meth: `tzinfo .dst ` method must consider times in the "missing hour" (2:MM for
16321631Eastern) to be in daylight time.
16331632
16341633When DST ends (the "end" line), there's a potentially worse problem: there's an
0 commit comments