[gnumeric] WEEKDAY: Update with new methods.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] WEEKDAY: Update with new methods.
- Date: Tue, 5 Aug 2014 18:37:00 +0000 (UTC)
commit a5de7954567f0bc788c7a8b8fba6daac88940209
Author: Morten Welinder <terra gnome org>
Date: Tue Aug 5 14:36:27 2014 -0400
WEEKDAY: Update with new methods.
NEWS | 1 +
plugins/fn-date/ChangeLog | 5 +++++
plugins/fn-date/functions.c | 38 ++++++++++++++++++++++++++++++++++----
3 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index d0b77c2..7d14697 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Andreas:
Morten:
* Fix xls export problem. [#733771]
+ * Update WEEKDAY function.
--------------------------------------------------------------------------
Gnumeric 1.12.17
diff --git a/plugins/fn-date/ChangeLog b/plugins/fn-date/ChangeLog
index 55f64f6..3e21fdb 100644
--- a/plugins/fn-date/ChangeLog
+++ b/plugins/fn-date/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-05 Morten Welinder <terra gnome org>
+
+ * functions.c (gnumeric_weekday): Add methods 11-17 from newer
+ Excel.
+
2014-06-09 Morten Welinder <terra gnome org>
* Release 1.12.17
diff --git a/plugins/fn-date/functions.c b/plugins/fn-date/functions.c
index 842176d..1a98ad9 100644
--- a/plugins/fn-date/functions.c
+++ b/plugins/fn-date/functions.c
@@ -652,6 +652,13 @@ static GnmFuncHelp const help_weekday[] = {
{ GNM_FUNC_HELP_NOTE, F_("If @{method} is 1, then Sunday is 1, Monday is 2, etc.") },
{ GNM_FUNC_HELP_NOTE, F_("If @{method} is 2, then Monday is 1, Tuesday is 2, etc.") },
{ GNM_FUNC_HELP_NOTE, F_("If @{method} is 3, then Monday is 0, Tuesday is 1, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 11, then Monday is 1, Tuesday is 2, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 12, then Tuesday is 1, Wednesday is 2, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 13, then Wednesday is 1, Thursday is 2, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 14, then Thursday is 1, Friday is 2, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 15, then Friday is 1, Saturday is 2, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 16, then Saturday is 1, Sunday is 2, etc.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{method} is 17, then Sunday is 1, Monday is 2, etc.") },
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_EXAMPLES, "=WEEKDAY(DATE(1940,4,9))" },
{ GNM_FUNC_HELP_SEEALSO, "DATE,ISOWEEKNUM"},
@@ -665,16 +672,39 @@ gnumeric_weekday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
int res;
gnm_float method = argv[1] ? value_get_as_float (argv[1]) : 1;
- if (method < 1 || method >= 4)
+ if (method < 1 || method >= G_MAXINT)
return value_new_error_NUM (ei->pos);
if (!datetime_value_to_g (&date, argv[0], DATE_CONV (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;
+ case 1:
+ case 17:
+ res = (g_date_get_weekday (&date) % 7) + 1;
+ break;
+ case 2:
+ case 11:
+ res = (g_date_get_weekday (&date) + 6) % 7 + 1;
+ break;
+ case 3:
+ res = (g_date_get_weekday (&date) + 6) % 7;
+ break;
+ case 12:
+ res = (g_date_get_weekday (&date) + 5) % 7 + 1;
+ break;
+ case 13:
+ res = (g_date_get_weekday (&date) + 4) % 7 + 1;
+ break;
+ case 14:
+ res = (g_date_get_weekday (&date) + 3) % 7 + 1;
+ break;
+ case 15:
+ res = (g_date_get_weekday (&date) + 2) % 7 + 1;
+ break;
+ case 16:
+ res = (g_date_get_weekday (&date) + 1) % 7 + 1;
+ break;
default:
return value_new_error_NUM (ei->pos);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]