[Gnucash-changes] Fix leap-year computation in the 'last_mday'
computation.
Derek Atkins
warlord at cvs.gnucash.org
Sun Feb 6 15:54:02 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.
Tags:
----
gnucash-1-8-branch
Modified Files:
--------------
gnucash:
ChangeLog
gnucash/src/engine:
date.c
Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1461.2.395
retrieving revision 1.1461.2.396
diff -LChangeLog -LChangeLog -u -r1.1461.2.395 -r1.1461.2.396
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,9 @@
+2004-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: date.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Attic/date.c,v
retrieving revision 1.59.2.2
retrieving revision 1.59.2.3
diff -Lsrc/engine/date.c -Lsrc/engine/date.c -u -r1.59.2.2 -r1.59.2.3
--- src/engine/date.c
+++ src/engine/date.c
@@ -175,12 +175,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