diff options
author | Eike Rathke <erack@redhat.com> | 2024-12-09 19:03:44 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2024-12-11 12:15:56 +0100 |
commit | dd57ef3aee60b24fecbb990a3fc2fc51ce30c9e4 (patch) | |
tree | 6233941693eb8c9a0c48cc991a163a39f8e5fef3 | |
parent | 4788e8dafad50748425527bcf90a8c3778266410 (diff) |
Resolves: tdf#164239 Can force Y-M-D to ISO 8601 if no date acceptance pattern
... was matched at all, even for a-b-c with MDY a<=12 or DMY a<=31.
Change-Id: Ie2d62c73c91794a96114b787d6ad2357c7affb2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178171
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 47b4b1633a08dd4c97d66feabe8cd3290074dc0f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178174
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit 224c0bb32232a29d08611365d25be1c340032bc8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178191
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | svl/qa/unit/svl.cxx | 21 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 4 |
2 files changed, 16 insertions, 9 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 3a8f5f51b43e..0d303569489d 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1161,7 +1161,7 @@ void Test::testIsNumberFormat() { "Sept 1", true }, //tdf#127363 { "5/d", false }, //tdf#143165 { "Jan 1 2000", true }, - { "5-12-14", false }, + { "5-12-14", true }, // tdf#164239 { "005-12-14", true }, { "15-10-30", true }, { "2015-10-30", true }, @@ -1223,26 +1223,28 @@ void checkSpecificNumberFormats( SvNumberFormatter& rFormatter, void Test::testIsNumberFormatSpecific() { { - // en-US uses M/D/Y format, test that a-b-c input with a<=31 and b<=12 - // does not lead to a/b/c date output + // en-US uses M/D/Y format, test that without Y-M-D pattern an a-b-c + // input with a<=12 leads to ISO a-b-c date output. SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US); std::vector<FormatInputOutput> aIO = { - { "5-12-14", false, "", 0 }, - { "32-12-14", true, "1932-12-14", 0 } + { "005-12-14", true, "0005-12-14", 0 }, + { "5-12-14", true, "2005-12-14", 0 }, + { "32-12-14", true, "1932-12-14", 0 } }; checkSpecificNumberFormats( aFormatter, aIO, "[en-US] date"); } { - // de-DE uses D.M.Y format, test that a-b-c input with a<=31 and b<=12 - // does not lead to a.b.c date output + // de-DE uses D.M.Y format, test that without Y-M-D pattern an a-b-c + // input with a<=31 leads to ISO a-b-c date output. SvNumberFormatter aFormatter(m_xContext, LANGUAGE_GERMAN); std::vector<FormatInputOutput> aIO = { - { "5-12-14", false, "", 0 }, - { "32-12-14", true, "1932-12-14", 0 } + { "005-12-14", true, "0005-12-14", 0 }, + { "5-12-14", true, "2005-12-14", 0 }, + { "32-12-14", true, "1932-12-14", 0 } }; checkSpecificNumberFormats( aFormatter, aIO, "[de-DE] date"); @@ -1254,6 +1256,7 @@ void Test::testIsNumberFormatSpecific() SvNumberFormatter aFormatter(m_xContext, LANGUAGE_DUTCH); std::vector<FormatInputOutput> aIO = { + { "001-2-11", true, "0001-02-11", 0 }, { "22-11-1999", true, "22-11-99", 0 }, // if default YY changes to YYYY adapt this { "1999-11-22", true, "1999-11-22", 0 }, { "1-2-11", true, "01-02-11", 0 }, // if default YY changes to YYYY adapt this diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 9db901463a71..584d98ed932d 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -1172,6 +1172,10 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder ) eDateOrder = GetDateOrder(); } + // No date pattern matched at all can be forced to ISO 8601 here as is. + if (GetDatePatternNumbers() == 0) + return true; + nCanForceToIso8601 = 1; } |