Fixed bug in time-to-midnight calculation.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 16 Jan 2006 09:08:06 +0000 (09:08 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 16 Jan 2006 09:08:06 +0000 (09:08 +0000)
Lib/logging/handlers.py

index 1ec9afcdc3d0ad22d3c6698e2ef29a8d668e362a..6225f17f9678cea81a0b42cd03d6e2467031b9a7 100644 (file)
@@ -212,9 +212,12 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
             currentMinute = t[4]
             currentSecond = t[5]
             # r is the number of seconds left between now and midnight
-            r = (24 - currentHour) * 60 * 60 # number of hours in seconds
-            r = r + (59 - currentMinute) * 60 # plus the number of minutes (in secs)
-            r = r + (59 - currentSecond) # plus the number of seconds
+            if (currentMinute == 0) and (currentSecond == 0):
+                r = (24 - currentHour) * 60 * 60 # number of hours in seconds
+            else:
+                r = (23 - currentHour) * 60 * 60
+                r = r + (59 - currentMinute) * 60 # plus the number of minutes (in secs)
+                r = r + (60 - currentSecond) # plus the number of seconds
             self.rolloverAt = currentTime + r
             # If we are rolling over on a certain day, add in the number of days until
             # the next rollover, but offset by 1 since we just calculated the time