[gnumeric] DATEDIF: fix problem across bogus 1900-02-29.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] DATEDIF: fix problem across bogus 1900-02-29.
- Date: Tue, 8 Dec 2009 19:26:39 +0000 (UTC)
commit aa5baf3452062647bf0b0de0e237e12f75eaaed0
Author: Morten Welinder <terra gnome org>
Date: Tue Dec 8 14:26:13 2009 -0500
DATEDIF: fix problem across bogus 1900-02-29.
NEWS | 1 +
plugins/fn-date/ChangeLog | 5 +++++
plugins/fn-date/functions.c | 7 ++++---
3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index b449ec0..c4b9d53 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Morten:
* Fix selection problem. [#601107]
* Automate solver testing.
* Fix SUMIF problem. [#603671]
+ * Fix DATEDIF problem across bogus 1900-02-29. [#599461]
--------------------------------------------------------------------------
Gnumeric 1.9.16
diff --git a/plugins/fn-date/ChangeLog b/plugins/fn-date/ChangeLog
index 29be780..e8ae5fa 100644
--- a/plugins/fn-date/ChangeLog
+++ b/plugins/fn-date/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-08 Morten Welinder <terra gnome org>
+
+ * functions.c (gnumeric_datedif): Go via GDate, even for "d" case.
+ Fixes #599461 and a few other things.
+
2009-11-29 Morten Welinder <terra gnome org>
* Release 1.9.16
diff --git a/plugins/fn-date/functions.c b/plugins/fn-date/functions.c
index 19de7b4..6e14992 100644
--- a/plugins/fn-date/functions.c
+++ b/plugins/fn-date/functions.c
@@ -323,15 +323,16 @@ gnumeric_datedif (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (date1 > date2)
return value_new_error_NUM (ei->pos);
- if (!strcmp (opt, "d"))
- return value_new_int (date2 - date1);
go_date_serial_to_g (&d1, date1, conv);
go_date_serial_to_g (&d2, date2, conv);
if (!g_date_valid (&d1) || !g_date_valid (&d2))
return value_new_error_VALUE (ei->pos);
- if (!strcmp (opt, "m"))
+ if (!strcmp (opt, "d"))
+ return value_new_int (g_date_get_julian (&d2) -
+ g_date_get_julian (&d1));
+ else if (!strcmp (opt, "m"))
return value_new_int (go_date_g_months_between (&d1, &d2));
else if (!strcmp (opt, "y"))
return value_new_int (go_date_g_years_between (&d1, &d2));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]