svl/source/numbers/zformat.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
New commits: commit c3247f0380b4ffe90672a0442687593531c5774b Author: Eike Rathke <er...@redhat.com> AuthorDate: Mon Oct 24 17:06:09 2022 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Mon Oct 24 20:28:50 2022 +0200 Use constexpr kTimeSignificantRound for all occurrences Change-Id: I3d55c5ee0d0e7a803f95c0fe9f67ee15fe814b65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141773 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index b3a547c28d3f..4aa5543ed5d3 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -62,6 +62,8 @@ const double EXP_ABS_UPPER_BOUND = 1.0E15; // use exponential notation above th // also sal/rtl/math.cxx // doubleToString() +constexpr sal_Int32 kTimeSignificantRound = 7; // Round (date+)time at 7 decimals + // (+5 of 86400 == 12 significant digits). } // namespace const double D_MAX_U_INT32 = double(0xffffffff); // 4294967295.0 @@ -3069,10 +3071,10 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber, bool bInputLine; sal_Int32 nCntPost; if ( rScan.GetStandardPrec() == SvNumberFormatter::INPUTSTRING_PRECISION && - 0 < rInfo.nCntPost && rInfo.nCntPost < 7 ) - { // round at 7 decimals (+5 of 86400 == 12 significant digits) + 0 < rInfo.nCntPost && rInfo.nCntPost < kTimeSignificantRound ) + { bInputLine = true; - nCntPost = 7; + nCntPost = kTimeSignificantRound; } else { @@ -3954,20 +3956,18 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber, const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); bool bInputLine; sal_Int32 nCntPost, nFirstRounding; - // Round at 7 decimals (+5 of 86400 == 12 significant digits). - constexpr sal_Int32 kSignificantRound = 7; if ( rScan.GetStandardPrec() == SvNumberFormatter::INPUTSTRING_PRECISION && - 0 < rInfo.nCntPost && rInfo.nCntPost < kSignificantRound ) + 0 < rInfo.nCntPost && rInfo.nCntPost < kTimeSignificantRound ) { bInputLine = true; - nCntPost = nFirstRounding = kSignificantRound; + nCntPost = nFirstRounding = kTimeSignificantRound; } else { bInputLine = false; nCntPost = rInfo.nCntPost; // For clock format (not []) do not round up to seconds and thus days. - nFirstRounding = (rInfo.bThousand ? nCntPost : kSignificantRound); + nFirstRounding = (rInfo.bThousand ? nCntPost : kTimeSignificantRound); } double fTime = (fNumber - floor( fNumber )) * 86400.0; fTime = ::rtl::math::round( fTime, int(nFirstRounding) );