]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1321: Fixed logic error in TimedRotatingFileHandler.__init__()
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 24 Oct 2007 10:47:06 +0000 (10:47 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 24 Oct 2007 10:47:06 +0000 (10:47 +0000)
Lib/logging/handlers.py

index 9807f1312d28ac96f9e20fdf39032761863491ab..fa203cf5ae8aafc5615d52af0816fe7eb56876b8 100644 (file)
@@ -230,11 +230,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
             #         of days in the next week until the rollover day (3).
             if when.startswith('W'):
                 day = t[6] # 0 is Monday
-                if day > self.dayOfWeek:
-                    daysToWait = (day - self.dayOfWeek) - 1
-                    self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
-                if day < self.dayOfWeek:
-                    daysToWait = (6 - self.dayOfWeek) + day
+                if day != self.dayOfWeek:
+                    if day < self.dayOfWeek:
+                        daysToWait = self.dayOfWeek - day - 1
+                    else:
+                        daysToWait = 6 - day + self.dayOfWeek
                     self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
 
         #print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)