diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 1b90ee5c8b88..80ec80e0d87e 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1170,7 +1170,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 }, @@ -1232,26 +1232,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 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 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"); @@ -1263,6 +1265,7 @@ void Test::testIsNumberFormatSpecific() SvNumberFormatter aFormatter(m_xContext, LANGUAGE_DUTCH); std::vector 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 13cdcb3ca53b..2b91fa662845 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; }