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
This commit is contained in:
parent
8f7294223a
commit
47b4b1633a
2 changed files with 16 additions and 9 deletions
|
@ -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<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");
|
||||
|
@ -1263,6 +1265,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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue