Kaydet (Commit) 00bb8e4a authored tarafından Eike Rathke's avatar Eike Rathke

Number scanner: accept fractional separators in an ISO 8601 date+time string

In a strict ISO 8601 date+time string with 'T' separator the
Time100SecSep separating seconds and fractional seconds can be
either '.' period or ',' comma, so accept those in all locales.

Not accepting '.' in all locales was the cause of tdf#100822
before code was changed to use sax::Converter::parseDateTime()
instead.

Change-Id: Ica676050b52b11da64afbac6feabb43d9e985bc4
üst 6537fac1
...@@ -120,6 +120,7 @@ void ImpSvNumberInputScan::Reset() ...@@ -120,6 +120,7 @@ void ImpSvNumberInputScan::Reset()
nStringScanSign = 0; nStringScanSign = 0;
nMatchedAllStrings = nMatchedVirgin; nMatchedAllStrings = nMatchedVirgin;
nMayBeIso8601 = 0; nMayBeIso8601 = 0;
bIso8601Tsep = false;
nMayBeMonthDate = 0; nMayBeMonthDate = 0;
nAcceptedDatePattern = -2; nAcceptedDatePattern = -2;
nDatePatternStart = 0; nDatePatternStart = 0;
...@@ -805,6 +806,18 @@ inline bool ImpSvNumberInputScan::GetTime100SecSep( const OUString& rString, sal ...@@ -805,6 +806,18 @@ inline bool ImpSvNumberInputScan::GetTime100SecSep( const OUString& rString, sal
{ {
if ( rString.getLength() > nPos ) if ( rString.getLength() > nPos )
{ {
if (bIso8601Tsep)
{
// ISO 8601 specifies both '.' dot and ',' comma as fractional
// separator.
if (rString[nPos] == '.' || rString[nPos] == ',')
{
++nPos;
return true;
}
}
// Even in an otherwise ISO 8601 string be lenient and accept the
// locale defined separator.
const OUString& rSep = pFormatter->GetLocaleData()->getTime100SecSep(); const OUString& rSep = pFormatter->GetLocaleData()->getTime100SecSep();
if ( rString.match( rSep, nPos )) if ( rString.match( rSep, nPos ))
{ {
...@@ -2549,6 +2562,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString, ...@@ -2549,6 +2562,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
{ {
// ISO 8601 combined date and time, yyyy-mm-ddThh:mm or -yyyy-mm-ddThh:mm // ISO 8601 combined date and time, yyyy-mm-ddThh:mm or -yyyy-mm-ddThh:mm
++nPos; ++nPos;
bIso8601Tsep = true;
} }
else if (nStringPos == 7 && rString[0] == ':') else if (nStringPos == 7 && rString[0] == ':')
{ {
......
...@@ -137,6 +137,9 @@ private: ...@@ -137,6 +137,9 @@ private:
*/ */
sal_uInt8 nMayBeIso8601; sal_uInt8 nMayBeIso8601;
/** Whether the 'T' time separator was detected in an ISO 8601 string. */
bool bIso8601Tsep;
/** State of dd-month-yy or yy-month-dd detection, with month name. /** State of dd-month-yy or yy-month-dd detection, with month name.
0:= don't know yet 0:= don't know yet
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment