Skip to content

Commit 80ebe95

Browse files
committed
Bug python#1321: Fixed logic error in TimedRotatingFileHandler.__init__()
1 parent 85375ee commit 80ebe95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/logging/handlers.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None)
231231
# of days in the next week until the rollover day (3).
232232
if when.startswith('W'):
233233
day = t[6] # 0 is Monday
234-
if day > self.dayOfWeek:
235-
daysToWait = (day - self.dayOfWeek) - 1
236-
self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
237-
if day < self.dayOfWeek:
238-
daysToWait = (6 - self.dayOfWeek) + day
234+
if day != self.dayOfWeek:
235+
if day < self.dayOfWeek:
236+
daysToWait = self.dayOfWeek - day - 1
237+
else:
238+
daysToWait = 6 - day + self.dayOfWeek
239239
self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
240240

241241
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)

0 commit comments

Comments
 (0)