[Gnucash-changes] Fix leap-year computation in the 'last_mday' computation.

Derek Atkins warlord at cvs.gnucash.org
Sun Feb 6 15:56:11 EST 2005


Log Message:
-----------
Fix leap-year computation in the 'last_mday' computation.

	* src/engine/date.c: Fix the last-day-of-month computation for
	  leap years.  Need to use modulo, not divide.  (Patch by
	  Neil Williams.

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/engine:
        gnc-date.c

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1889
retrieving revision 1.1890
diff -LChangeLog -LChangeLog -u -r1.1889 -r1.1890
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,9 @@
+2005-02-06  Derek Atkins  <derek at ihtfp.com>
+
+	* src/engine/date.c: Fix the last-day-of-month computation for
+	  leap years.  Need to use modulo, not divide.  (Patch by
+	  Neil Williams.
+
 2005-02-06  Christian Stimming  <stimming at tuhh.de>
 
 	* src/import-export/hbci/gnc-hbci-gettrans.c: Fix HBCI date range
Index: gnc-date.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-date.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lsrc/engine/gnc-date.c -Lsrc/engine/gnc-date.c -u -r1.9 -r1.10
--- src/engine/gnc-date.c
+++ src/engine/gnc-date.c
@@ -260,12 +260,12 @@
      /*   leap   */ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
 
   /* Is this a leap year? */
-  if (year / 2000 == 0)
+  if (year % 2000 == 0)
     is_leap = TRUE;
-  else if (year / 400 == 0)
+  else if (year % 400 == 0)
       is_leap = FALSE;
   else
-    is_leap = (year / 4 == 0);
+    is_leap = (year % 4 == 0);
 
   return days_in_month[is_leap][month-1];
 }


More information about the gnucash-changes mailing list