gnumeric r17025 - in trunk: . plugins/fn-date
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17025 - in trunk: . plugins/fn-date
- Date: Mon, 15 Dec 2008 21:52:50 +0000 (UTC)
Author: mortenw
Date: Mon Dec 15 21:52:50 2008
New Revision: 17025
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17025&view=rev
Log:
2008-12-15 Morten Welinder <terra gnome org>
* functions.c (gnumeric_month, gnumeric_year, gnumeric_day):
Return an error in case of error. What a concept!
(gnumeric_weekday): Use #NUM! error for compatibility.
Modified:
trunk/NEWS
trunk/plugins/fn-date/ChangeLog
trunk/plugins/fn-date/functions.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Mon Dec 15 21:52:50 2008
@@ -57,6 +57,7 @@
* Improve sc import. Not sure why. [#564495]
* Fix date overflow problem. [#564502]
* Fix XLS import critical. [#564499]
+ * Sanitize error cases for DAY, MONTH, YEAR.
--------------------------------------------------------------------------
Gnumeric 1.9.3
Modified: trunk/plugins/fn-date/functions.c
==============================================================================
--- trunk/plugins/fn-date/functions.c (original)
+++ trunk/plugins/fn-date/functions.c Mon Dec 15 21:52:50 2008
@@ -718,12 +718,12 @@
static GnmValue *
gnumeric_year (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- int res = 1900;
GDate date;
if (datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos)))
- res = g_date_get_year (&date);
- return value_new_int (res);
+ return value_new_int (g_date_get_year (&date));
+ else
+ return value_new_error_NUM (ei->pos);
}
/***************************************************************************/
@@ -752,12 +752,12 @@
static GnmValue *
gnumeric_month (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- int res = 1;
GDate date;
if (datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos)))
- res = g_date_get_month (&date);
- return value_new_int (res);
+ return value_new_int (g_date_get_month (&date));
+ else
+ return value_new_error_NUM (ei->pos);
}
/***************************************************************************/
@@ -786,12 +786,12 @@
static GnmValue *
gnumeric_day (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- int res = 1;
GDate date;
if (datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos)))
- res = g_date_get_day (&date);
- return value_new_int (res);
+ return value_new_int (g_date_get_day (&date));
+ else
+ return value_new_error_NUM (ei->pos);
}
/***************************************************************************/
@@ -832,17 +832,17 @@
gnm_float method = argv[1] ? value_get_as_float (argv[1]) : 1;
if (method < 1 || method >= 4)
- return value_new_error_VALUE (ei->pos);
+ return value_new_error_NUM (ei->pos);
if (!datetime_value_to_g (&date, argv[0], DATE_CONV (ei->pos)))
- return value_new_error_VALUE (ei->pos);
+ return value_new_error_NUM (ei->pos);
switch ((int)method) {
case 1: res = (g_date_get_weekday (&date) % 7) + 1; break;
case 2: res = (g_date_get_weekday (&date) + 6) % 7 + 1; break;
case 3: res = (g_date_get_weekday (&date) + 6) % 7; break;
default:
- return value_new_error_VALUE (ei->pos);
+ return value_new_error_NUM (ei->pos);
}
return value_new_int (res);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]