[gnumeric] csv: be less aggressive in guessing date formats
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] csv: be less aggressive in guessing date formats
- Date: Mon, 10 Jun 2019 00:22:59 +0000 (UTC)
commit eed9e1436b1ed618cb12e08635dab382014f76d6
Author: Morten Welinder <terra gnome org>
Date: Sun Jun 9 20:21:54 2019 -0400
csv: be less aggressive in guessing date formats
Specifically, insist on having all of year, month, and day-of-month.
NEWS | 3 +++
configure.ac | 2 +-
src/stf-parse.c | 15 +++++++++++++--
3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 9c3a0e4ef..7d3227f97 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.12.46
+Morten:
+ * Fix over-eager guessing of dates in csv. [#401]
+
--------------------------------------------------------------------------
Gnumeric 1.12.45
diff --git a/configure.ac b/configure.ac
index 5fb52b896..a905c9676 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,7 +166,7 @@ PKG_PROG_PKG_CONFIG(0.18)
dnl *****************************
libspreadsheet_reqs="
- libgoffice-${GOFFICE_API_VER} >= 0.10.42
+ libgoffice-${GOFFICE_API_VER} >= 0.10.46
libgsf-1 >= 1.14.33
libxml-2.0 >= 2.4.12
"
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 135de8662..3e0cfa109 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -1828,8 +1828,9 @@ do_check_date (const char *data, StfGuessFormats flag,
GODateConventions const *date_conv)
{
GnmValue *v;
- gboolean this_mbd, this_ybm;
+ gboolean has_all, this_mbd, this_ybm;
int imbd;
+ GOFormat const *fmt;
if (!(*possible & flag))
return;
@@ -1838,7 +1839,17 @@ do_check_date (const char *data, StfGuessFormats flag,
if (!v || !VALUE_FMT (v))
goto fail;
- imbd = go_format_month_before_day (VALUE_FMT (v));
+ fmt = VALUE_FMT (v);
+ has_all = (go_format_has_year (fmt) &&
+ go_format_has_month (fmt) &&
+ go_format_has_day (fmt));
+ if (!has_all) {
+ // See #401
+ // Avoid detecting 1.9999 is a date.
+ goto fail;
+ }
+
+ imbd = go_format_month_before_day (fmt);
this_mbd = (imbd >= 1);
this_ybm = (imbd == 2);
if (mbd != this_mbd || ybm != this_ybm)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]