Suggested patch for timeperiod daterange problem

Mike Bird mgb-debian at yosemite.net
Sun Jun 1 01:05:45 CEST 2008


Since we started using "day 1 - -1" in timeperiod objects a
few months back we've experienced problems on the last day of
each month with checks and notifications not occurring.

The problem seems to be in base/utils.c:

--- base/utils.c.original	2008-03-10 13:58:33.000000000 -0700
+++ base/utils.c	2008-05-31 15:45:09.000000000 -0700
@@ -1523,7 +1523,7 @@
 		/* make the new time */
 		t.tm_mon=month;
 		t.tm_year=year;
-		t.tm_mday+=(monthday<-30)?-30:monthday;
+		t.tm_mday+=(monthday<-30)?-30:monthday+1;
 		midnight=mktime(&t);
 
 		/* if we rolled over to the previous month, time is invalid */

On entry into the above code, t.tm_mday is the last day of the month.
Adding a monthday of -1 changes t.tm_mday to the day before the last
day of the month, but -1 is supposed to mean the last day of the month.
Therefore we have to add +1 to compensate.

(The above patch is against version 3.0.1 via Debian.)

--Mike Bird

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/




More information about the Developers mailing list