[Libreoffice-commits] core.git: svl/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Sat Oct 19 10:30:02 UTC 2019
svl/source/numbers/zforfind.cxx | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
New commits:
commit d639f40886c89daee453a42e247ae657517f5504
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Sat Oct 19 11:05:27 2019 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Sat Oct 19 12:29:26 2019 +0200
We don't support leap seconds, but.. accept as input anyway
Change-Id: If83b42066ffd928c9832e60ea05382ffc42fed84
Reviewed-on: https://gerrit.libreoffice.org/81122
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 90debaadb205..cd889ce4d9d6 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -977,6 +977,20 @@ bool ImpSvNumberInputScan::GetTimeRef( double& fOutNumber,
bRet = false;
SAL_WARN( "svl.numbers", "ImpSvNumberInputScan::GetTimeRef: bad number index");
}
+
+ if (nAmPm && nHour > 12) // not a valid AM/PM clock time
+ {
+ bRet = false;
+ }
+ else if (nAmPm == -1 && nHour != 12) // PM
+ {
+ nHour += 12;
+ }
+ else if (nAmPm == 1 && nHour == 12) // 12 AM
+ {
+ nHour = 0;
+ }
+
if (nDecPos == 2 && nCnt == 2) // 45.5
{
nMinute = 0;
@@ -990,25 +1004,13 @@ bool ImpSvNumberInputScan::GetTimeRef( double& fOutNumber,
if (nIndex - nStartIndex < nCnt)
{
nSecond = static_cast<sal_uInt16>(sStrArray[nNums[nIndex++]].toInt32());
- if (nIndex > 1 && nSecond > 59)
- bRet = false; // 1:60 or 1:123 or 1:1:123 is invalid, 123:1 or 123:1:1 is valid
+ if (nIndex > 1 && nSecond > 59 && !(nHour == 23 && nMinute == 59 && nSecond == 60))
+ bRet = false; // 1:60 or 1:123 or 1:1:123 is invalid, 123:1 or 123:1:1 is valid, or leap second
}
if (nIndex - nStartIndex < nCnt)
{
fSecond100 = StringToDouble( sStrArray[nNums[nIndex]], true );
}
- if (nAmPm && nHour > 12) // not a valid AM/PM clock time
- {
- bRet = false;
- }
- else if (nAmPm == -1 && nHour != 12) // PM
- {
- nHour += 12;
- }
- else if (nAmPm == 1 && nHour == 12) // 12 AM
- {
- nHour = 0;
- }
fOutNumber = (static_cast<double>(nHour)*3600 +
static_cast<double>(nMinute)*60 +
static_cast<double>(nSecond) +
More information about the Libreoffice-commits
mailing list