[gnumeric] number formats: add 2020-Oct-11 as an allowed date format.



commit c4293745d790bfeb9f8e3db57172d5f074b3c8bf
Author: Morten Welinder <terra gnome org>
Date:   Tue Oct 20 19:10:23 2020 -0400

    number formats: add 2020-Oct-11 as an allowed date format.
    
    Fairly harmless.

 src/number-match.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/src/number-match.c b/src/number-match.c
index ac470e344..4b1554960 100644
--- a/src/number-match.c
+++ b/src/number-match.c
@@ -109,6 +109,7 @@ static struct {
        GORegexp re_yyyymmdd1;
        GORegexp re_yyyymmdd2;
        GORegexp re_yyyymmdd3;
+       GORegexp re_yyyymmdd4;
        GORegexp re_mmddyyyy;
        GORegexp re_mmdd;
        GORegexp re_hhmmss1;
@@ -127,6 +128,7 @@ datetime_locale_clear (void)
        go_regfree (&datetime_locale.re_yyyymmdd1);
        go_regfree (&datetime_locale.re_yyyymmdd2);
        go_regfree (&datetime_locale.re_yyyymmdd3);
+       go_regfree (&datetime_locale.re_yyyymmdd4);
        go_regfree (&datetime_locale.re_mmddyyyy);
        go_regfree (&datetime_locale.re_mmdd);
        go_regfree (&datetime_locale.re_hhmmss1);
@@ -263,6 +265,16 @@ datetime_locale_setup (char const *lc_time)
        datetime_locale_setup1 (&datetime_locale.re_yyyymmdd3,
                                "^(\\d\\d\\d\\d)[-/.](\\d+)[-/.](\\d+)\\b");
 
+       /*
+        * "2000-Oct-10"
+        */
+       s = g_strconcat ("^(\\d\\d\\d\\d)[-/.](",
+                        p_MMM->str,
+                        ")[-/.](\\d+)\\b",
+                        NULL);
+       datetime_locale_setup1 (&datetime_locale.re_yyyymmdd4, s);
+       g_free (s);
+
        /*
         * "01/31/2001"    [Jan 31] if month_before_day
         * "1/2/88"        [Jan 2]  if month_before_day
@@ -770,6 +782,20 @@ format_match_datetime (char const *text,
                }
        }
 
+       /* ^(\d\d\d\d)[-/.](MMM)[-/.](\d+)\b */
+       /*  1              2         15      */
+       if (dig1 > 0 &&  /* Exclude zero.  */
+           go_regexec (&datetime_locale.re_yyyymmdd4, text, G_N_ELEMENTS (match), match, 0) == 0) {
+               year = handle_year (text, match + 1);
+               month = find_month (match + 3);
+               day = handle_day (text, match + 15);
+               if (valid_dmy (day, month, year)) {
+                       date_format = g_strdup ("yyyy-mmm-dd");
+                       text += match[0].rm_eo;
+                       goto got_date;
+               }
+       }
+
        /* ^(\d+)[-/.](\d+)[-/.](\d+)\b */
        /*  1         2         3   */
        if (dig1 >= 0 &&


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