diff options
author | Eike Rathke <erack@redhat.com> | 2019-10-19 11:05:27 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-10-19 12:29:26 +0200 |
commit | d639f40886c89daee453a42e247ae657517f5504 (patch) | |
tree | 236993f0f7631da9d13263d8ca34e4d10ff2e13c /svl | |
parent | 82f2b7fd80353758f35dee9d6e7e80a5e77eb526 (diff) |
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@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 30 |
1 files changed, 16 insertions, 14 deletions
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) + |