[goffice] Fix US 30/360 date calculations. [#631242][#630784]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fix US 30/360 date calculations. [#631242][#630784]
- Date: Sun, 3 Oct 2010 18:13:41 +0000 (UTC)
commit 64a3da87a54c2b85245a55624dab66a209907505
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Oct 3 12:12:56 2010 -0600
Fix US 30/360 date calculations. [#631242][#630784]
2010-10-03 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/datetime.c (days_between_GO_BASIS_MSRB_30_360):
fix calculation, see 631242 and 630784.
ChangeLog | 5 +++++
NEWS | 3 +++
goffice/utils/datetime.c | 12 +++++++++---
3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 405a3c0..91aeb16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-03 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * goffice/utils/datetime.c (days_between_GO_BASIS_MSRB_30_360):
+ fix calculation, see 631242 and 630784.
+
2010-10-01 Morten Welinder <terra gnome org>
* configure.in: Post-release bump.
diff --git a/NEWS b/NEWS
index c12c6b2..7a51ffa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.8.12:
+Andreas
+ * Fix US 30/360 date calculations. [#631242][#630784]
+
--------------------------------------------------------------------------
goffice 0.8.11:
diff --git a/goffice/utils/datetime.c b/goffice/utils/datetime.c
index 28941c7..b683c48 100644
--- a/goffice/utils/datetime.c
+++ b/goffice/utils/datetime.c
@@ -261,12 +261,18 @@ days_between_GO_BASIS_MSRB_30_360 (GDate const *from, GDate const *to)
m2 = g_date_get_month (to);
d2 = g_date_get_day (to);
- if (m1 == 2 && g_date_is_last_of_month (from))
+ if (d1 == d2 && m1 == m2 && y1 == y2)
+ return 0;
+ if (d1 == 31)
d1 = 30;
- if (d2 == 31 && d1 >= 30)
+ if (d2 == 31 && d1 == 30)
d2 = 30;
- if (d1 == 31)
+
+ if (m1 == 2 && g_date_is_last_of_month (from)) {
+ if (m2 == 2 && g_date_is_last_of_month (to))
+ d2 = 30;
d1 = 30;
+ }
return (y2 - y1) * 360 + (m2 - m1) * 30 + (d2 - d1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]