gnumeric r16669 - in trunk: . plugins/fn-date
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16669 - in trunk: . plugins/fn-date
- Date: Wed, 25 Jun 2008 13:57:26 +0000 (UTC)
Author: mortenw
Date: Wed Jun 25 13:57:26 2008
New Revision: 16669
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16669&view=rev
Log:
2008-06-25 Morten Welinder <terra gnome org>
* functions.c (gnumeric_eomonth): Work around glib problem. Fixes
#540069.
Modified:
trunk/NEWS
trunk/plugins/fn-date/ChangeLog
trunk/plugins/fn-date/functions.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Wed Jun 25 13:57:26 2008
@@ -1,5 +1,8 @@
Gnumeric 1.9.2
+Morten:
+ * Fix EOMONTH issue. [#540069]
+
--------------------------------------------------------------------------
Gnumeric 1.9.1
Modified: trunk/plugins/fn-date/functions.c
==============================================================================
--- trunk/plugins/fn-date/functions.c (original)
+++ trunk/plugins/fn-date/functions.c Wed Jun 25 13:57:26 2008
@@ -472,9 +472,9 @@
/* Pretest for the benefit of #539868 */
if (y > 9999 || y < 1900)
g_date_clear (&date, 1);
- else if (months > 0)
+ else if (m > 0)
g_date_add_months (&date, m);
- else
+ else if (m < 0)
g_date_subtract_months (&date, -m);
if (!g_date_valid (&date) ||
@@ -961,6 +961,7 @@
gnm_float months = argv[1] ? value_get_as_float (argv[1]) : 0;
GDate date;
GODateConventions const *conv = DATE_CONV (ei->pos);
+ int m, y;
datetime_value_to_g (&date, argv[0], conv);
if (!g_date_valid (&date))
@@ -969,10 +970,16 @@
if (months > INT_MAX / 2 || -months > INT_MAX / 2)
return value_new_error_NUM (ei->pos);
- if (months > 0)
- g_date_add_months (&date, (int)months);
- else if (months < 0)
- g_date_subtract_months (&date, (int)-months);
+ m = (int)months;
+ y = g_date_get_year (&date) + m / 12;
+
+ /* Pretest for the benefit of #539868 */
+ if (y > 9999 || y < 1900)
+ g_date_clear (&date, 1);
+ else if (m > 0)
+ g_date_add_months (&date, m);
+ else if (m < 0)
+ g_date_subtract_months (&date, -m);
if (!g_date_valid (&date) ||
g_date_get_year (&date) < 1900 ||
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]