[gnumeric] Sheet: add new sheet_date_conv convenience function.



commit c1c76eb28ae2a8f71e065b3da7df2d7ffb166513
Author: Morten Welinder <terra gnome org>
Date:   Sun May 6 12:31:21 2018 -0400

    Sheet: add new sheet_date_conv convenience function.
    
    This is not a hint that date conventions are per-sheet.  They are per
    workbook and will stay that way.

 ChangeLog                                 |    2 +-
 OChangeLog-2012-12-18                     |    2 +-
 plugins/fn-christian-date/functions.c     |    2 +-
 plugins/fn-date/functions.c               |    2 +-
 plugins/fn-eng/functions.c                |    2 +-
 plugins/fn-financial/functions.c          |   46 ++++++++++++++--------------
 plugins/fn-hebrew-date/functions.c        |    2 +-
 plugins/fn-info/functions.c               |    2 +-
 plugins/fn-math/functions.c               |    4 +-
 plugins/fn-string/functions.c             |   10 +++---
 plugins/gda/plugin-gda.c                  |    2 +-
 src/cell.c                                |    4 +-
 src/clipboard.c                           |    6 ++--
 src/collect.c                             |    2 +-
 src/criteria.c                            |    3 +-
 src/dialogs/dialog-cell-format.c          |    6 +--
 src/dialogs/dialog-function-select.c      |    3 +-
 src/expr.c                                |   16 +++++-----
 src/func.c                                |    4 +-
 src/graph.c                               |   12 ++++----
 src/mathfunc.c                            |    2 +-
 src/parse-util.c                          |    2 +-
 src/rendered-value.c                      |    2 +-
 src/search.c                              |    3 +-
 src/sheet-autofill.c                      |    6 ++--
 src/sheet-control-gui.c                   |    3 +-
 src/sheet-filter.c                        |    6 ++--
 src/sheet-object-widget.c                 |    2 +-
 src/sheet.c                               |   16 ++++++++++
 src/sheet.h                               |    2 +
 src/stf-export.c                          |    2 +-
 src/stf-parse.c                           |    3 +-
 src/tools/fill-series.c                   |   14 ++++----
 src/value.c                               |    5 ++-
 src/wbc-gtk-actions.c                     |    3 +-
 src/wbc-gtk-edit.c                        |    3 +-
 src/widgets/gnm-filter-combo-view.c       |    2 +-
 src/widgets/gnm-sheet-slicer-combo-view.c |    2 +-
 src/widgets/gnm-validation-combo-view.c   |    2 +-
 src/widgets/gnumeric-expr-entry.c         |   12 ++++----
 src/workbook.c                            |    2 +-
 src/xml-sax-read.c                        |    3 +-
 src/xml-sax-write.c                       |    2 +-
 43 files changed, 120 insertions(+), 111 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4874b02..d406834 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3413,7 +3413,7 @@
        * src/ssdiff.c (diff): Use C locale.
        (ignore_cell): Ignore arrays, except for the corner.
        (output_cell): New function taking proper care of value types,
-       convensions, etc.
+       conventions, etc.
        (xml_cell_changed): Use output_cell.
        (compare_corresponding_cells): Don't use entered_text here either,
        although it's harmless.
diff --git a/OChangeLog-2012-12-18 b/OChangeLog-2012-12-18
index 4590015..29174ea 100644
--- a/OChangeLog-2012-12-18
+++ b/OChangeLog-2012-12-18
@@ -5341,7 +5341,7 @@
        dependent_managed_set_expr): New functions.
 
        * src/value.c (value_new_cellrange_parsepos_str): Use the right
-       convensions.  Add flags argument for finer control.  All callers
+       conventions.  Add flags argument for finer control.  All callers
        changed.
 
 2009-10-31  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/fn-christian-date/functions.c b/plugins/fn-christian-date/functions.c
index 8df9376..f4d408b 100644
--- a/plugins/fn-christian-date/functions.c
+++ b/plugins/fn-christian-date/functions.c
@@ -40,7 +40,7 @@
 
 GNM_PLUGIN_MODULE_HEADER;
 
-#define DATE_CONV(ep)          workbook_date_conv ((ep)->sheet->workbook)
+#define DATE_CONV(ep)          sheet_date_conv ((ep)->sheet)
 
 static void
 eastersunday_calc_for_year (int year, GDate *date)
diff --git a/plugins/fn-date/functions.c b/plugins/fn-date/functions.c
index 2d19ed6..cdb1c48 100644
--- a/plugins/fn-date/functions.c
+++ b/plugins/fn-date/functions.c
@@ -45,7 +45,7 @@
 GNM_PLUGIN_MODULE_HEADER;
 
 #define DAY_SECONDS (3600*24)
-#define DATE_CONV(ep)          workbook_date_conv ((ep)->sheet->workbook)
+#define DATE_CONV(ep)          sheet_date_conv ((ep)->sheet)
 
 static GnmValue *
 make_date (GnmValue *res)
diff --git a/plugins/fn-eng/functions.c b/plugins/fn-eng/functions.c
index dcfb986..af09ff1 100644
--- a/plugins/fn-eng/functions.c
+++ b/plugins/fn-eng/functions.c
@@ -93,7 +93,7 @@ val_to_base (GnmFuncEvalInfo *ei,
                if (flags & V2B_STRINGS_GENERAL) {
                        vstring = format_match_number
                                (value_peek_string (value), NULL,
-                                workbook_date_conv (ei->pos->sheet->workbook));
+                                sheet_date_conv (ei->pos->sheet));
                        if (!vstring || !VALUE_IS_FLOAT (vstring)) {
                                value_release (vstring);
                                return value_new_error_VALUE (ei->pos);
diff --git a/plugins/fn-financial/functions.c b/plugins/fn-financial/functions.c
index 56c6dc5..c3c7428 100644
--- a/plugins/fn-financial/functions.c
+++ b/plugins/fn-financial/functions.c
@@ -337,7 +337,7 @@ func_coup (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
         conv.freq  = value_get_freq (argv[2]);
        conv.basis = value_get_basis (argv[3], GO_BASIS_MSRB_30_360);
        conv.eom   = argv[4] ? value_get_as_checked_bool (argv[4]) : TRUE;
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
         if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
            !datetime_value_to_g (&maturity, argv[1], conv.date_conv))
@@ -401,7 +401,7 @@ gnumeric_accrint (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gboolean   calc_method;
 
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
         if (!datetime_value_to_g (&issue, argv[0], date_conv) ||
            !datetime_value_to_g (&first_interest, argv[1], date_conv) ||
@@ -466,7 +466,7 @@ gnumeric_accrintm (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float rate, a, d, par;
        int basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        rate  = value_get_as_float (argv[2]);
        par   = argv[3] ? value_get_as_float (argv[3]) : 1000;
@@ -504,7 +504,7 @@ gnumeric_intrate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float investment, redemption, a, d;
        int basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        investment = value_get_as_float (argv[2]);
        redemption = value_get_as_float (argv[3]);
@@ -542,7 +542,7 @@ gnumeric_received (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float investment, discount, a, d, n;
        int basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        investment = value_get_as_float (argv[2]);
        discount   = value_get_as_float (argv[3]);
@@ -582,7 +582,7 @@ gnumeric_pricedisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float discount, redemption, a, d;
        int basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        discount   = value_get_as_float (argv[2]);
        redemption = value_get_as_float (argv[3]);
@@ -619,7 +619,7 @@ gnumeric_pricemat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float discount, yield, a, b, dsm, dim, n;
        int basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        discount = value_get_as_float (argv[3]);
        yield    = value_get_as_float (argv[4]);
@@ -664,7 +664,7 @@ gnumeric_disc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float par, redemption, dsm, b;
        int basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        par        = value_get_as_float (argv[2]);
        redemption = value_get_as_float (argv[3]);
@@ -1098,7 +1098,7 @@ gnumeric_tbilleq (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float settlement, maturity, discount;
        gnm_float dsm, divisor;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        settlement = datetime_value_to_serial (argv[0], date_conv);
        maturity   = datetime_value_to_serial (argv[1], date_conv);
@@ -1136,7 +1136,7 @@ gnumeric_tbillprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float settlement, maturity, discount;
        gnm_float res, dsm;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        settlement = datetime_value_to_serial (argv[0], date_conv);
        maturity   = datetime_value_to_serial (argv[1], date_conv);
@@ -1170,7 +1170,7 @@ gnumeric_tbillyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float settlement, maturity, pr;
        gnm_float res, dsm;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        settlement = datetime_value_to_serial (argv[0], date_conv);
        maturity   = datetime_value_to_serial (argv[1], date_conv);
@@ -1911,7 +1911,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         gnm_float fNumOfCoups;
        GoCouponConvention conv;
 
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
        conv.eom = TRUE;
 
        fCoup      = value_get_as_float (argv[2]);
@@ -2274,7 +2274,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float rate, yield, redemption;
        GoCouponConvention conv;
 
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
        rate       = value_get_as_float (argv[2]);
        yield      = value_get_as_float (argv[3]);
@@ -2347,7 +2347,7 @@ gnumeric_yield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         udata.conv.freq  = value_get_freq (argv[5]);
         udata.conv.basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
         udata.conv.eom   = TRUE;
-        udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+        udata.conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
        if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
            !datetime_value_to_g (&udata.maturity, argv[1], udata.conv.date_conv))
@@ -2431,7 +2431,7 @@ gnumeric_yielddisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gint      basis;
        gnm_float ret, yfrac;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        fPrice     = value_get_as_float (argv[2]);
        fRedemp    = value_get_as_float (argv[3]);
@@ -2476,7 +2476,7 @@ gnumeric_yieldmat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float fRate, fPrice;
        gint      basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        fRate      = value_get_as_float (argv[3]);
        fPrice     = value_get_as_float (argv[4]);
@@ -2618,7 +2618,7 @@ gnumeric_oddfprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         conv.eom   = TRUE;
         conv.freq  = value_get_freq (argv[7]);
         conv.basis = value_get_basis (argv[8], GO_BASIS_MSRB_30_360);
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
        if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
            !datetime_value_to_g (&maturity, argv[1], conv.date_conv) ||
@@ -2696,7 +2696,7 @@ gnumeric_oddfyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         udata.conv.eom   = TRUE;
         udata.conv.freq  = value_get_freq (argv[7]);
         udata.conv.basis = value_get_basis (argv[8], GO_BASIS_MSRB_30_360);
-       udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       udata.conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
        if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
            !datetime_value_to_g (&udata.maturity, argv[1], udata.conv.date_conv) ||
@@ -2794,7 +2794,7 @@ gnumeric_oddlprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         conv.eom   = TRUE;
         conv.freq  = value_get_freq (argv[6]);
         conv.basis = value_get_basis (argv[7], GO_BASIS_MSRB_30_360);
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
        if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
            !datetime_value_to_g (&maturity, argv[1], conv.date_conv) ||
@@ -2872,7 +2872,7 @@ gnumeric_oddlyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         conv.eom   = TRUE;
         conv.freq  = value_get_freq (argv[6]);
         conv.basis = value_get_basis (argv[7], GO_BASIS_MSRB_30_360);
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
 
        if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
            !datetime_value_to_g (&maturity, argv[1], conv.date_conv) ||
@@ -2932,7 +2932,7 @@ gnumeric_amordegrc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float fRestVal, fRate, fCost;
        gint      basis, nPer;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        fCost      = value_get_as_float (argv[0]);
        fRestVal   = value_get_as_float (argv[3]);
@@ -2978,7 +2978,7 @@ gnumeric_amorlinc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float fCost, fRestVal, fRate;
        gint      nPer, basis;
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
 
        fCost      = value_get_as_float (argv[0]);
        fRestVal   = value_get_as_float (argv[3]);
@@ -3259,7 +3259,7 @@ gnumeric_mduration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
         gnm_float fNumOfCoups;
        GoCouponConvention conv;
 
-       conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       conv.date_conv = sheet_date_conv (ei->pos->sheet);
        conv.eom = TRUE;
 
        fCoup      = value_get_as_float (argv[2]);
diff --git a/plugins/fn-hebrew-date/functions.c b/plugins/fn-hebrew-date/functions.c
index 92c3181..d5ab653 100644
--- a/plugins/fn-hebrew-date/functions.c
+++ b/plugins/fn-hebrew-date/functions.c
@@ -46,7 +46,7 @@
 
 GNM_PLUGIN_MODULE_HEADER;
 
-#define DATE_CONV(ep)               workbook_date_conv ((ep)->sheet->workbook)
+#define DATE_CONV(ep)               sheet_date_conv ((ep)->sheet)
 #define UNICODE_MONTH_PREFIX "\xd7\x91\xd6\xbc\xd6\xb0"
 
 static void
diff --git a/plugins/fn-info/functions.c b/plugins/fn-info/functions.c
index 3ab6f7c..6da353b 100644
--- a/plugins/fn-info/functions.c
+++ b/plugins/fn-info/functions.c
@@ -1750,7 +1750,7 @@ gnumeric_n (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
        v = format_match_number (value_peek_string (argv[0]),
                                 NULL,
-                                workbook_date_conv (ei->pos->sheet->workbook));
+                                sheet_date_conv (ei->pos->sheet));
        if (v != NULL)
                return v;
 
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 3c5e220..1b81d77 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -65,7 +65,7 @@ oldstyle_if_func (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
        GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)gnm_criteria_unref);
        GPtrArray *data = g_ptr_array_new ();
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
        GnmValue *res;
        gboolean insanity;
        GnmValue const *vals;
@@ -112,7 +112,7 @@ newstyle_if_func (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv,
        GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)gnm_criteria_unref);
        GPtrArray *data = g_ptr_array_new_with_free_func ((GDestroyNotify)value_release);
        GODateConventions const *date_conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
        GnmValue *res;
        GnmValue *vals = NULL;
        int i;
diff --git a/plugins/fn-string/functions.c b/plugins/fn-string/functions.c
index a2c6d3d..3c78a87 100644
--- a/plugins/fn-string/functions.c
+++ b/plugins/fn-string/functions.c
@@ -881,7 +881,7 @@ gnumeric_fixed (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        g_string_free (format, TRUE);
 
        res = format_value (fmt, v, -1,
-                           workbook_date_conv (ei->pos->sheet->workbook));
+                           sheet_date_conv (ei->pos->sheet));
 
        go_format_unref (fmt);
        value_release (v);
@@ -1079,7 +1079,7 @@ gnumeric_text (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        GnmValue *res, *match = NULL;
        GnmValue const *v  = argv[0];
        GODateConventions const *conv =
-               workbook_date_conv (ei->pos->sheet->workbook);
+               sheet_date_conv (ei->pos->sheet);
        char *lfmt;
 
        /* Why do we have to do these here?  */
@@ -1186,7 +1186,7 @@ gnumeric_value (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
                       p = g_utf8_next_char (p);
 
                v = format_match_number (p, NULL,
-                       workbook_date_conv (ei->pos->sheet->workbook));
+                       sheet_date_conv (ei->pos->sheet));
 
                if (v != NULL)
                        return v;
@@ -1245,7 +1245,7 @@ gnumeric_numbervalue (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
                if (v == NULL)
                        v = format_match_number
                                (p, NULL,
-                                workbook_date_conv (ei->pos->sheet->workbook));
+                                sheet_date_conv (ei->pos->sheet));
 
                if (v != NULL)
                        return v;
@@ -1390,7 +1390,7 @@ gnumeric_dollar (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
        v = value_new_float (number);
        s = format_value (sf, v, -1,
-                         workbook_date_conv (ei->pos->sheet->workbook));
+                         sheet_date_conv (ei->pos->sheet));
        value_release (v);
        go_format_unref (sf);
 
diff --git a/plugins/gda/plugin-gda.c b/plugins/gda/plugin-gda.c
index c800882..ff17ed0 100644
--- a/plugins/gda/plugin-gda.c
+++ b/plugins/gda/plugin-gda.c
@@ -157,7 +157,7 @@ display_recordset (GdaDataModel *recset, GnmFuncEvalInfo *ei)
        if (rowcount >= gnm_sheet_get_max_rows (ei->pos->sheet))
                return value_new_error (ei->pos, _("Too much data returned"));
 
-       date_conv = workbook_date_conv (ei->pos->sheet->workbook);
+       date_conv = sheet_date_conv (ei->pos->sheet);
        array = value_new_array_empty (fieldcount, rowcount);
        for (row = 0; row < rowcount; row++) {
                for (col = 0; col < fieldcount; col++) {
diff --git a/src/cell.c b/src/cell.c
index 24ecb03..a82a9de 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -731,7 +731,7 @@ gnm_cell_get_entered_text (GnmCell const *cell)
        v = cell->value;
        if (v != NULL) {
                GODateConventions const *date_conv =
-                       workbook_date_conv (sheet->workbook);
+                       sheet_date_conv (sheet);
 
                if (VALUE_IS_STRING (v)) {
                        /* Try to be reasonably smart about adding a leading quote */
@@ -830,7 +830,7 @@ gnm_cell_get_text_for_editing (GnmCell const * cell,
        if (quoted)
                *quoted = FALSE;
 
-       date_conv = workbook_date_conv (cell->base.sheet->workbook);
+       date_conv = sheet_date_conv (cell->base.sheet);
 
        if (!gnm_cell_is_array (cell) &&
            !gnm_cell_has_expr (cell) && VALUE_IS_FLOAT (cell->value)) {
diff --git a/src/clipboard.c b/src/clipboard.c
index 26da5b5..cc597a0 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -302,7 +302,7 @@ paste_cell (int target_col, int target_row,
                                        gnm_float fnew = go_date_conv_translate
                                                (value_get_as_float (oldval),
                                                 dat->cr->date_conv,
-                                                workbook_date_conv (dst_sheet->workbook));
+                                                sheet_date_conv (dst_sheet));
                                        newval = value_new_float (fnew);
                                        value_set_fmt (newval, VALUE_FMT (oldval));
                                }
@@ -554,7 +554,7 @@ clipboard_paste_region (GnmCellRegion const *cr,
        }
 
        dat.translate_dates = cr->date_conv &&
-               !go_date_conv_equal (cr->date_conv, workbook_date_conv (pt->sheet->workbook));
+               !go_date_conv_equal (cr->date_conv, sheet_date_conv (pt->sheet));
 
        for (i = 0; i < repeat_horizontal ; i++)
                for (j = 0; j < repeat_vertical ; j++) {
@@ -894,7 +894,7 @@ gnm_cell_region_new (Sheet *origin_sheet)
        GnmCellRegion *cr = g_new0 (GnmCellRegion, 1);
        cr->origin_sheet        = origin_sheet;
        cr->date_conv           = origin_sheet && origin_sheet->workbook
-               ? workbook_date_conv (origin_sheet->workbook)
+               ? sheet_date_conv (origin_sheet)
                : NULL;
        cr->cols = cr->rows     = -1;
        cr->not_as_contents     = FALSE;
diff --git a/src/collect.c b/src/collect.c
index e907b13..d9a36e6 100644
--- a/src/collect.c
+++ b/src/collect.c
@@ -490,7 +490,7 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
        cl.count = 0;
        cl.flags = flags;
        cl.info = NULL;
-       cl.date_conv = workbook_date_conv (ep->sheet->workbook);
+       cl.date_conv = sheet_date_conv (ep->sheet);
 
        *error = function_iterate_argument_values
                (ep, &callback_function_collect, &cl,
diff --git a/src/criteria.c b/src/criteria.c
index 57c5828..d3c4471 100644
--- a/src/criteria.c
+++ b/src/criteria.c
@@ -400,8 +400,7 @@ parse_criteria_range (Sheet *sheet, int b_col, int b_row, int e_col, int e_row,
                      int   *field_ind, gboolean anchor_end)
 {
        GSList *criterias = NULL;
-       GODateConventions const *date_conv =
-               workbook_date_conv (sheet->workbook);
+       GODateConventions const *date_conv = sheet_date_conv (sheet);
         int i, j;
 
        for (i = b_row; i <= e_row; i++) {
diff --git a/src/dialogs/dialog-cell-format.c b/src/dialogs/dialog-cell-format.c
index 5663d0a..4ce5aad 100644
--- a/src/dialogs/dialog-cell-format.c
+++ b/src/dialogs/dialog-cell-format.c
@@ -460,8 +460,7 @@ static void
 fmt_dialog_init_format_page (FormatState *state)
 {
        GOFormatSel *gfs;
-       GODateConventions const *date_conv =
-               workbook_date_conv (state->sheet->workbook);
+       GODateConventions const *date_conv = sheet_date_conv (state->sheet);
 
        state->format_sel = gnm_format_sel_new ();
        gfs = GO_FORMAT_SEL (state->format_sel);
@@ -860,8 +859,7 @@ fmt_dialog_init_font_page (FormatState *state)
        GtkWidget *font_widget;
        gboolean strikethrough = FALSE;
        GOFontScript script = GO_FONT_SCRIPT_STANDARD;
-       GODateConventions const *date_conv =
-               workbook_date_conv (state->sheet->workbook);
+       GODateConventions const *date_conv = sheet_date_conv (state->sheet);
        GnmColor *mcolor = NULL;
        GnmColor *def_sc;
        GtkWidget *up;
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index 3328fbc..5f74ef6 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -687,8 +687,7 @@ make_expr_example (Sheet *sheet, const char *text,
 
                if (!fmt)
                        fmt = gnm_auto_style_format_suggest (texpr, &ep);
-               vtxt = format_value (fmt, val, -1,
-                                    workbook_date_conv (sheet->workbook));
+               vtxt = format_value (fmt, val, -1, sheet_date_conv (sheet));
 
                gnm_expr_top_unref (texpr);
                value_release (val);
diff --git a/src/expr.c b/src/expr.c
index 52ca362..5febc26 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -904,7 +904,7 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
                a = va = (GnmValue *)value_zero;
        else if (VALUE_IS_STRING (a)) {
                va = format_match_number (value_peek_string (a), NULL,
-                       workbook_date_conv (ep->sheet->workbook));
+                       sheet_date_conv (ep->sheet));
                if (va == NULL)
                        return value_new_error_VALUE (ep);
        } else if (!VALUE_IS_NUMBER (a))
@@ -915,7 +915,7 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
                b = vb = (GnmValue *)value_zero;
        else if (VALUE_IS_STRING (b)) {
                vb = format_match_number (value_peek_string (b), NULL,
-                       workbook_date_conv (ep->sheet->workbook));
+                       sheet_date_conv (ep->sheet));
                if (vb == NULL) {
                        if (va != a)
                                value_release (va);
@@ -1119,7 +1119,7 @@ cb_iter_unary_neg (GnmValueIter const *v_iter, GnmValue *res)
        else if (VALUE_IS_STRING (v)) {
                GnmValue *conv = format_match_number (
                        value_peek_string (v), NULL,
-                       workbook_date_conv (v_iter->ep->sheet->workbook));
+                       sheet_date_conv (v_iter->ep->sheet));
                if (conv != NULL) {
                        tmp = negate_value (conv);
                        value_release (conv);
@@ -1150,7 +1150,7 @@ cb_iter_percentage (GnmValueIter const *v_iter, GnmValue *res)
                if (VALUE_IS_STRING (v)) {
                        conv = format_match_number (
                                value_peek_string (v), NULL,
-                               workbook_date_conv (v_iter->ep->sheet->workbook));
+                               sheet_date_conv (v_iter->ep->sheet));
                        if (conv != NULL)
                                v = conv;
                }
@@ -1301,7 +1301,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
                /* 2) #!VALUE error if A is not a number */
                if (VALUE_IS_STRING (a)) {
                        GnmValue *tmp = format_match_number (value_peek_string (a), NULL,
-                               workbook_date_conv (pos->sheet->workbook));
+                               sheet_date_conv (pos->sheet));
 
                        value_release (a);
                        if (tmp == NULL)
@@ -1311,7 +1311,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
                        b = gnm_expr_eval (expr->binary.value_b, pos, flags);
                        if (VALUE_IS_STRING (b)) {
                                res = format_match_number (value_peek_string (b), NULL,
-                                       workbook_date_conv (pos->sheet->workbook));
+                                       sheet_date_conv (pos->sheet));
                                value_release (b);
                                b = (res == NULL) ? value_new_error_VALUE (pos) : res;
                        }
@@ -1333,7 +1333,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
                /* 4) #!VALUE error if B is not a number */
                if (VALUE_IS_STRING (b)) {
                        GnmValue *tmp = format_match_number (value_peek_string (b), NULL,
-                               workbook_date_conv (pos->sheet->workbook));
+                               sheet_date_conv (pos->sheet));
 
                        value_release (b);
                        if (tmp == NULL) {
@@ -1377,7 +1377,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
                /* 2) #!VALUE error if A is not a number */
                if (VALUE_IS_STRING (a)) {
                        GnmValue *tmp = format_match_number (value_peek_string (a), NULL,
-                               workbook_date_conv (pos->sheet->workbook));
+                               sheet_date_conv (pos->sheet));
 
                        value_release (a);
                        if (tmp == NULL)
diff --git a/src/func.c b/src/func.c
index abfb1d0..7f84c6b 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1236,7 +1236,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
                case 'f':
                        if (VALUE_IS_STRING (tmp)) {
                                tmp = format_match_number (value_peek_string (tmp), NULL,
-                                       workbook_date_conv (ei->pos->sheet->workbook));
+                                       sheet_date_conv (ei->pos->sheet));
                                if (tmp == NULL) {
                                        free_values (args, i + 1);
                                        return value_new_error_VALUE (ei->pos);
@@ -1299,7 +1299,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
                                                        elem = value_zero;
                                                else if (VALUE_IS_STRING (elem)) {
                                                        tmp = format_match_number (value_peek_string (elem), 
NULL,
-                                                               workbook_date_conv 
(ei->pos->sheet->workbook));
+                                                               sheet_date_conv (ei->pos->sheet));
                                                        if (tmp != NULL) {
                                                                args [iter_item[i]] = iter_args [i] = tmp;
                                                                continue;
diff --git a/src/graph.c b/src/graph.c
index 0356999..5896b95 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -82,7 +82,7 @@ render_val (GnmValue const *v, int i, int j,
        if (!v)
                return NULL;
 
-       date_conv = ep->sheet ? workbook_date_conv (ep->sheet->workbook) : NULL;
+       date_conv = ep->sheet ? sheet_date_conv (ep->sheet) : NULL;
 
 #if 0
        g_printerr ("Rendering %s with fmt=%s\n",
@@ -181,7 +181,7 @@ gnm_go_data_date_conv (GOData const *dat)
        if (!dep->sheet)
                return NULL;
 
-       return workbook_date_conv (dep->sheet->workbook);
+       return sheet_date_conv (dep->sheet);
 }
 
 static char *
@@ -690,7 +690,7 @@ gnm_go_data_vector_load_values (GODataVector *dat)
                return;
        }
 
-       closure.date_conv = workbook_date_conv (vec->dep.sheet->workbook);
+       closure.date_conv = sheet_date_conv (vec->dep.sheet);
 
        if (dat->values == NULL)
                dat->values = g_new (double, dat->len);
@@ -914,7 +914,7 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
                        int x = 0, y = vec->val->v_array.y;
                        struct string_closure closure;
                        closure.strs = vec->strs = g_ptr_array_new_with_free_func (g_free);
-                       closure.date_conv = ep.sheet ? workbook_date_conv (ep.sheet->workbook) : NULL;
+                       closure.date_conv = ep.sheet ? sheet_date_conv (ep.sheet) : NULL;
                        while (len-- > 0) {
                                if (x == 0) {
                                        x = vec->val->v_array.x;
@@ -956,7 +956,7 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
                if (vec->strs == NULL) {
                        struct string_closure closure;
                        closure.strs = vec->strs = g_ptr_array_new_with_free_func (g_free);
-                       closure.date_conv = ep.sheet ? workbook_date_conv (ep.sheet->workbook) : NULL;
+                       closure.date_conv = ep.sheet ? sheet_date_conv (ep.sheet) : NULL;
                        gnm_rangeref_normalize (&vec->val->v_range.cell,
                                eval_pos_init_dep (&ep, &vec->dep),
                                &start_sheet, &end_sheet, &r);
@@ -1319,7 +1319,7 @@ gnm_go_data_matrix_load_values (GODataMatrix *dat)
                return;
        }
 
-       closure.date_conv = workbook_date_conv (mat->dep.sheet->workbook);
+       closure.date_conv = sheet_date_conv (mat->dep.sheet);
 
        if (dat->values == NULL)
                dat->values = g_new (double, size.rows * size.columns);
diff --git a/src/mathfunc.c b/src/mathfunc.c
index 10b4147..54014b0 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -22,7 +22,7 @@
 
 /*
  * NOTE 2: the pbeta (and support) code comes from Ian Smith.  (Translated
- * into C, adapted to Gnumeric naming convensions, and R's API conventions
+ * into C, adapted to Gnumeric naming conventions, and R's API conventions
  * by Morten Welinder.  Blame me for problems.)
  *
  * Copyright © Ian Smith 2002-2003
diff --git a/src/parse-util.c b/src/parse-util.c
index 3c4359c..ab34856 100644
--- a/src/parse-util.c
+++ b/src/parse-util.c
@@ -832,7 +832,7 @@ parse_text_value_or_expr (GnmParsePos const *pos, char const *text,
        /* Determine context information.  */
        date_conv =
                pos->sheet
-               ? workbook_date_conv (pos->sheet->workbook)
+               ? sheet_date_conv (pos->sheet)
                : (pos->wb
                   ? workbook_date_conv (pos->wb)
                   : NULL);
diff --git a/src/rendered-value.c b/src/rendered-value.c
index 131578b..4b2c032 100644
--- a/src/rendered-value.c
+++ b/src/rendered-value.c
@@ -447,7 +447,7 @@ gnm_rendered_value_new (GnmCell const *cell,
                int col_width = -1;
                GOFormat const *format = gnm_style_get_format (mstyle);
                GODateConventions const *date_conv = sheet->workbook
-                       ? workbook_date_conv (sheet->workbook)
+                       ? sheet_date_conv (sheet)
                        : NULL;
                GnmFont *font = gnm_style_get_font (mstyle, context);
                gboolean is_rotated = (rotation != 0);
diff --git a/src/search.c b/src/search.c
index 1af1ea5..6414f63 100644
--- a/src/search.c
+++ b/src/search.c
@@ -76,8 +76,7 @@ gnm_search_normalize_result (const char *txt)
 static gboolean
 check_number (GnmSearchReplace *sr)
 {
-       GODateConventions const *date_conv =
-               workbook_date_conv (sr->sheet->workbook);
+       GODateConventions const *date_conv = sheet_date_conv (sr->sheet);
        GOSearchReplace *gosr = (GOSearchReplace *)sr;
        GnmValue *v = format_match_number (gosr->search_text, NULL, date_conv);
 
diff --git a/src/sheet-autofill.c b/src/sheet-autofill.c
index 2532eba..d72e7e2 100644
--- a/src/sheet-autofill.c
+++ b/src/sheet-autofill.c
@@ -165,7 +165,7 @@ afa_teach_cell (AutoFiller *af, const GnmCell *cell, int n)
 
        switch (n) {
        case 0:
-               afa->dateconv = workbook_date_conv (cell->base.sheet->workbook);
+               afa->dateconv = sheet_date_conv (cell->base.sheet);
                afa->base = f;
                if (afa->singleton) {
                        afa->step = 1;
@@ -546,7 +546,7 @@ afm_teach_cell (AutoFiller *af, const GnmCell *cell, int n)
        if (gnm_format_is_date_for_value (sf, value) != 1)
                goto bad;
 
-       afm->dateconv = workbook_date_conv (cell->base.sheet->workbook);
+       afm->dateconv = sheet_date_conv (cell->base.sheet);
        if (!datetime_value_to_g (&d, value, afm->dateconv))
                goto bad;
 
@@ -902,7 +902,7 @@ afc_set_cell_hint (AutoFiller *af, GnmCell *cell, GnmCellPos const *pos,
                else {
                        Sheet const *sheet = src->base.sheet;
                        GODateConventions const *dateconv =
-                               workbook_date_conv (sheet->workbook);
+                               sheet_date_conv (sheet);
                        GOFormat const *format = gnm_cell_get_format (src);
                        return format_value (format, src->value, -1,
                                             dateconv);
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index f623f98..df18ea6 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -4504,10 +4504,9 @@ static void
 scg_drag_send_text (SheetControlGUI *scg, GtkSelectionData *sd)
 {
        Sheet *sheet = scg_sheet (scg);
-       Workbook *wb = sheet->workbook;
        GnmRange range = sheet_get_extent (sheet, TRUE, TRUE);
        GnmCellRegion *reg = clipboard_copy_range (sheet, &range);
-       GString *s = cellregion_to_string (reg, TRUE, workbook_date_conv (wb));
+       GString *s = cellregion_to_string (reg, TRUE, sheet_date_conv (sheet));
 
        cellregion_unref (reg);
        if (!s)
diff --git a/src/sheet-filter.c b/src/sheet-filter.c
index 2b5aaa7..4466664 100644
--- a/src/sheet-filter.c
+++ b/src/sheet-filter.c
@@ -191,7 +191,7 @@ filter_expr_init (FilterExpr *fexpr, unsigned i,
                GnmFilterOp op = cond->op[i];
                char const *str = value_peek_string (tmp);
                GODateConventions const *date_conv =
-                       workbook_date_conv (filter->sheet->workbook);
+                       sheet_date_conv (filter->sheet);
 
                if ((op == GNM_FILTER_OP_EQUAL || op == GNM_FILTER_OP_NOT_EQUAL) &&
                    gnm_regcomp_XL (fexpr->regexp + i, str, GO_REG_ICASE, TRUE, TRUE) == GO_REG_OK) {
@@ -221,7 +221,7 @@ filter_cell_contents (GnmCell *cell)
 {
        GOFormat const *format = gnm_cell_get_format (cell);
        GODateConventions const *date_conv =
-               workbook_date_conv (cell->base.sheet->workbook);
+               sheet_date_conv (cell->base.sheet);
        return format_value (format, cell->value, -1, date_conv);
 }
 
@@ -258,7 +258,7 @@ filter_expr_eval (GnmFilterOp op, GnmValue const *src, GORegexp const *regexp,
 
        if (VALUE_IS_STRING (target) && VALUE_IS_NUMBER (src)) {
                GODateConventions const *date_conv =
-                       workbook_date_conv (cell->base.sheet->workbook);
+                       sheet_date_conv (cell->base.sheet);
                char *str = format_value (NULL, src, -1, date_conv);
                fake_val = value_new_string_nocopy (str);
                src = fake_val;
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index c6501c9..97a39fd 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -3197,7 +3197,7 @@ static GnmValue *
 so_parse_value (SheetObject *so, const char *s)
 {
        Sheet *sheet = so->sheet;
-       return format_match (s, NULL, workbook_date_conv (sheet->workbook));
+       return format_match (s, NULL, sheet_date_conv (sheet));
 }
 
 static void
diff --git a/src/sheet.c b/src/sheet.c
index caff828..523dcfd 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -6669,3 +6669,19 @@ gnm_sheet_find_sort_setup (Sheet *sheet, char const *key)
                return NULL;
        return g_hash_table_lookup (sheet->sort_setups, key);
 }
+
+/**
+ * sheet_date_conv:
+ * @sheet: #Sheet
+ *
+ * Returns: (transfer none): the date conventions in effect for the sheet.
+ * This is purely a convenience function to access the conventions used
+ * for the workbook.  All sheets in a workbook share the same date
+ * conventions.
+ **/
+GODateConventions const *
+sheet_date_conv (Sheet const *sheet)
+{
+       g_return_val_if_fail (IS_SHEET (sheet), NULL);
+       return workbook_date_conv (sheet->workbook);
+}
diff --git a/src/sheet.h b/src/sheet.h
index 5984fde..589f00c 100644
--- a/src/sheet.h
+++ b/src/sheet.h
@@ -403,6 +403,8 @@ GOUndo *sheet_clear_region_undo (GnmSheetRange *sr,
 
 SheetView *sheet_get_view (Sheet const *sheet, WorkbookView const *wbv);
 
+GODateConventions const *sheet_date_conv (Sheet const *sheet);
+
 // Introspection support
 void sheet_cell_set_value_gi (Sheet *sheet, int col, int row, GnmValue *v);
 void sheet_cell_set_text_gi  (Sheet *sheet, int col, int row, char const *str);
diff --git a/src/stf-export.c b/src/stf-export.c
index 162428c..0c0d530 100644
--- a/src/stf-export.c
+++ b/src/stf-export.c
@@ -245,7 +245,7 @@ stf_export_cell (GnmStfExport *stfe, GnmCell *cell)
                case GNM_STF_FORMAT_AUTO:
                        if (cell->value) {
                                GODateConventions const *date_conv =
-                                       workbook_date_conv (cell->base.sheet->workbook);
+                                       sheet_date_conv (cell->base.sheet);
                                GOFormat const *format = gnm_cell_get_format (cell);
                                text = tmp = try_auto_date (cell->value, format, date_conv);
                                if (!text)
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 8e5d7e8..05b64e1 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -1240,8 +1240,7 @@ stf_cell_set_text (GnmCell *cell, char const *text)
        GnmExprTop const *texpr;
        GnmValue *val;
        GOFormat const *fmt = gnm_style_get_format (gnm_cell_get_style (cell));
-       const GODateConventions *date_conv =
-               workbook_date_conv (cell->base.sheet->workbook);
+       const GODateConventions *date_conv = sheet_date_conv (cell->base.sheet);
 
        if (!go_format_is_text (fmt) && *text == '=' && text[1] != 0) {
                GnmExprParseFlags flags =
diff --git a/src/tools/fill-series.c b/src/tools/fill-series.c
index ec2e0ac..6281748 100644
--- a/src/tools/fill-series.c
+++ b/src/tools/fill-series.c
@@ -50,7 +50,7 @@ do_row_filling_wday (data_analysis_output_t *dao, fill_series_t *info)
        gnm_float start = info->start_value;
        GDate        date;
        GODateConventions const *conv =
-               workbook_date_conv (dao->sheet->workbook);
+               sheet_date_conv (dao->sheet);
 
 
        for (i = 0; i < info->n; i++) {
@@ -77,7 +77,7 @@ do_column_filling_wday (data_analysis_output_t *dao, fill_series_t *info)
        gnm_float start = info->start_value;
        GDate        date;
        GODateConventions const *conv =
-               workbook_date_conv (dao->sheet->workbook);
+               sheet_date_conv (dao->sheet);
 
 
        for (i = 0; i < info->n; i++) {
@@ -105,7 +105,7 @@ do_row_filling_month (data_analysis_output_t *dao, fill_series_t *info)
        gnm_float start = info->start_value;
        GDate        date;
        GODateConventions const *conv =
-               workbook_date_conv (dao->sheet->workbook);
+               sheet_date_conv (dao->sheet);
 
 
        for (i = 0; i < info->n; i++) {
@@ -124,7 +124,7 @@ do_column_filling_month (data_analysis_output_t *dao, fill_series_t *info)
        gnm_float start = info->start_value;
        GDate        date;
        GODateConventions const *conv =
-               workbook_date_conv (dao->sheet->workbook);
+               sheet_date_conv (dao->sheet);
 
 
        for (i = 0; i < info->n; i++) {
@@ -143,7 +143,7 @@ do_row_filling_year (data_analysis_output_t *dao, fill_series_t *info)
        gnm_float start = info->start_value;
        GDate        date;
        GODateConventions const *conv =
-               workbook_date_conv (dao->sheet->workbook);
+               sheet_date_conv (dao->sheet);
 
 
        for (i = 0; i < info->n; i++) {
@@ -162,7 +162,7 @@ do_column_filling_year (data_analysis_output_t *dao, fill_series_t *info)
        gnm_float start = info->start_value;
        GDate        date;
        GODateConventions const *conv =
-               workbook_date_conv (dao->sheet->workbook);
+               sheet_date_conv (dao->sheet);
 
 
        for (i = 0; i < info->n; i++) {
@@ -242,7 +242,7 @@ fill_series_adjust_variables (data_analysis_output_t *dao, fill_series_t *info)
                if (info->is_stop_set) {
                        GDate        from_date, to_date;
                        GODateConventions const *conv =
-                               workbook_date_conv (dao->sheet->workbook);
+                               sheet_date_conv (dao->sheet);
 
                        if (info->step_value < 0) {
                                go_date_serial_to_g (&from_date,
diff --git a/src/value.c b/src/value.c
index 21358e0..af27c5e 100644
--- a/src/value.c
+++ b/src/value.c
@@ -1237,8 +1237,9 @@ value_coerce_to_number (GnmValue *v, gboolean *valid, GnmEvalPos const *ep)
 
        *valid = FALSE;
        if (VALUE_IS_STRING (v)) {
-               GnmValue *tmp = format_match_number (value_peek_string (v), NULL,
-                       workbook_date_conv (ep->sheet->workbook));
+               GnmValue *tmp =
+                       format_match_number (value_peek_string (v), NULL,
+                                            sheet_date_conv (ep->sheet));
                value_release (v);
                if (tmp == NULL)
                        return value_new_error_VALUE (ep);
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 1fc9c01..884a3f6 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -784,8 +784,7 @@ insert_date_time_common (WBCGtk *wbcg, gboolean do_date, gboolean do_time)
                GnmCell const *cell = sheet_cell_fetch (sheet,
                                                        sv->edit_pos.col,
                                                        sv->edit_pos.row);
-               GODateConventions const *date_conv =
-                       workbook_date_conv (sheet->workbook);
+               GODateConventions const *date_conv = sheet_date_conv (sheet);
                GnmValue *v = value_new_float
                        (go_date_timet_to_serial_raw (time (NULL), date_conv));
                char *txt;
diff --git a/src/wbc-gtk-edit.c b/src/wbc-gtk-edit.c
index 01cf18e..bef8839 100644
--- a/src/wbc-gtk-edit.c
+++ b/src/wbc-gtk-edit.c
@@ -242,8 +242,7 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
                fmt = gnm_cell_get_format (sheet_cell_fetch (sheet, sv->edit_pos.col,
                                                             sv->edit_pos.row));
 
-               value = format_match (txt, fmt,
-                                     workbook_date_conv (sheet->workbook));
+               value = format_match (txt, fmt, sheet_date_conv (sheet));
                if (value == NULL)
                        expr_txt = gnm_expr_char_start_p (txt);
                else
diff --git a/src/widgets/gnm-filter-combo-view.c b/src/widgets/gnm-filter-combo-view.c
index d932f1f..99f7ad8 100644
--- a/src/widgets/gnm-filter-combo-view.c
+++ b/src/widgets/gnm-filter-combo-view.c
@@ -192,7 +192,7 @@ fcombo_create_list (SheetObject *so,
        uc.hash = g_hash_table_new_full ((GHashFunc)value_hash, (GEqualFunc)formatted_value_equal,
                (GDestroyNotify)value_release, (GDestroyNotify)g_free);
        uc.src_sheet = filter->sheet;
-       uc.date_conv = workbook_date_conv (uc.src_sheet->workbook);
+       uc.date_conv = sheet_date_conv (uc.src_sheet);
 
        /* We do not want to show items that are filtered by _other_ fields.
         * The cleanest way to do that is to create a temporary sheet, apply
diff --git a/src/widgets/gnm-sheet-slicer-combo-view.c b/src/widgets/gnm-sheet-slicer-combo-view.c
index 1c80d9f..a315809 100644
--- a/src/widgets/gnm-sheet-slicer-combo-view.c
+++ b/src/widgets/gnm-sheet-slicer-combo-view.c
@@ -100,7 +100,7 @@ sscombo_create_list (SheetObject *so,
        GOVal const     *v;
        GString         *str;
        unsigned i;
-       GODateConventions const *dconv = workbook_date_conv (sscombo->parent.sv->sheet->workbook);
+       GODateConventions const *dconv = sheet_date_conv (sscombo->parent.sv->sheet);
 
        vals = go_data_cache_field_get_vals (dcf, TRUE);
        if (NULL == vals)
diff --git a/src/widgets/gnm-validation-combo-view.c b/src/widgets/gnm-validation-combo-view.c
index 40c2c1a..1781dd9 100644
--- a/src/widgets/gnm-validation-combo-view.c
+++ b/src/widgets/gnm-validation-combo-view.c
@@ -117,7 +117,7 @@ vcombo_create_list (SheetObject *so,
        if (NULL == v)
                return NULL;
 
-       uc.date_conv = workbook_date_conv (sv->sheet->workbook);
+       uc.date_conv = sheet_date_conv (sv->sheet);
        uc.hash = g_hash_table_new_full ((GHashFunc)value_hash, (GEqualFunc)value_equal,
                (GDestroyNotify)value_release, (GDestroyNotify)g_free);
        value_area_foreach (v, &ep, CELL_ITER_IGNORE_BLANK,
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 6a58626..9f82fc6 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -361,7 +361,7 @@ static GnmValue *
 get_matched_value (GnmExprEntry *gee)
 {
        GODateConventions const *date_conv =
-               workbook_date_conv (gee->sheet->workbook);
+               sheet_date_conv (gee->sheet);
        const char *text = gnm_expr_entry_get_text (gee);
 
        return format_match_number (text, gee->constant_format, date_conv);
@@ -374,7 +374,7 @@ gee_update_calendar (GnmExprEntry *gee)
        GDate date;
        GnmValue *v;
        GODateConventions const *date_conv =
-               workbook_date_conv (gee->sheet->workbook);
+               sheet_date_conv (gee->sheet);
 
        if (!gee->calendar_combo)
                return;
@@ -401,7 +401,7 @@ cb_calendar_changed (GOCalendarButton *calb, GnmExprEntry *gee)
 {
        GDate date;
        GODateConventions const *date_conv =
-               workbook_date_conv (gee->sheet->workbook);
+               sheet_date_conv (gee->sheet);
        int serial;
 
        if (!go_calendar_button_get_date (calb, &date))
@@ -1626,7 +1626,7 @@ gee_data_editor_set_format (GogDataEditor *deditor, GOFormat const *fmt)
        GnmExprEntry *gee = (GnmExprEntry *)deditor;
        GnmValue *v;
        GODateConventions const *date_conv =
-               workbook_date_conv (gee->sheet->workbook);
+               sheet_date_conv (gee->sheet);
 
        if (fmt == gee->constant_format)
                return;
@@ -2619,7 +2619,7 @@ gnm_expr_entry_parse (GnmExprEntry *gee, GnmParsePos const *pp,
                GnmValue *v = get_matched_value (gee);
                if (v) {
                        GODateConventions const *date_conv =
-                               workbook_date_conv (gee->sheet->workbook);
+                               sheet_date_conv (gee->sheet);
                        GnmExprTop const *texpr = gnm_expr_top_new_constant (v);
                        char *str = format_value (gee->constant_format, v, -1, date_conv);
                        if (gee_debug)
@@ -2720,7 +2720,7 @@ gnm_expr_entry_parse_as_value (GnmExprEntry *gee, Sheet *sheet)
 
        if (!v && (gee->flags & GNM_EE_CONSTANT_ALLOWED)) {
                GODateConventions const *date_conv =
-                       sheet ? workbook_date_conv (sheet->workbook) : NULL;
+                       sheet ? sheet_date_conv (sheet) : NULL;
                v = format_match_number (txt, NULL, date_conv);
        }
 
diff --git a/src/workbook.c b/src/workbook.c
index 89b23e6..8184891 100644
--- a/src/workbook.c
+++ b/src/workbook.c
@@ -1351,7 +1351,7 @@ workbook_sheet_reorder (Workbook *wb, GSList *new_order)
  * workbook_date_conv:
  * @wb: Workbook
  *
- * Returns: the date convention in effect for the workbook.
+ * Returns: (transfer none): the date conventions in effect for the workbook.
  **/
 GODateConventions const *
 workbook_date_conv (Workbook const *wb)
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 746d2ee..b3b7017 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2579,8 +2579,7 @@ xml_sax_object_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 static GnmValue *
 parse_constraint_side (const char *s, const GnmParsePos *pp)
 {
-       GODateConventions const *date_conv =
-               workbook_date_conv (pp->sheet->workbook);
+       GODateConventions const *date_conv = sheet_date_conv (pp->sheet);
        GnmValue *v = format_match_number (s, NULL, date_conv);
 
        if (!v) {
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 03af5af..21168ae 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -1658,7 +1658,7 @@ gnm_cellregion_to_xml (GnmCellRegion const *cr)
        if (cr->origin_sheet)
                xml_write_date_conventions_as_attr
                        (&state.state,
-                        workbook_date_conv (cr->origin_sheet->workbook));
+                        sheet_date_conv (cr->origin_sheet));
        xml_write_number_system (&state.state);
        if (cr->not_as_contents)
                gsf_xml_out_add_bool (state.state.output, "NotAsContent", TRUE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]