diff options
author | Eike Rathke <erack@redhat.com> | 2019-05-07 23:17:45 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-10 22:27:19 +0200 |
commit | f01e31762b02b8b896e726238eb2475c0e01ef82 (patch) | |
tree | b6167edcd0072b9617d3d25e9993209c0779b8fd /sc/source | |
parent | 232b467083dd3b55f261bebe084e696bee200ec9 (diff) |
Resolves: tdf#125099 round duration results in interpreter already
This is a combination of 3 commits.
Resolves: tdf#125099 round duration results in interpreter already
So wall clock time formats less likely display a one-off value,
duration formats are too rarely used if the expected duration is
less than 24 hours.
Reviewed-on: https://gerrit.libreoffice.org/71909
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 85c0521f01f5c726e9f754b3175a550121e566c8)
Test RANK(), not the underlying floating point representation of duration
The RANK() results depended on the floating point representation
of time differences (durations), which for visually equal MM:SS
display values don't have to be equal if similar durations result
from different start and end times. Change that to a well defined
duration in seconds.
b69a6b43f48abd2d4fe605021acfd2800e75b5e1
Reviewed-on: https://gerrit.libreoffice.org/71926
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 8de7949050d63fd9f7ac41e1a2442849580b86fa)
Fix typed flags bitmask, tdf#125099 follow-up
25327cfcafc9e1f2e88b388677853c638dd9b0e6
Reviewed-on: https://gerrit.libreoffice.org/71946
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit d27ad84ec7a0aafb07d6a6152c686f4bc802f661)
Change-Id: I9b0872420699b17e3ed3f20993f8cfe02761f862
Reviewed-on: https://gerrit.libreoffice.org/71935
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 21 | ||||
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 9 |
2 files changed, 26 insertions, 4 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index cc3672cbdbeb..57ab5aec29a2 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -4433,6 +4433,7 @@ StackVar ScInterpreter::Interpret() case SvNumFormatType::DATE: case SvNumFormatType::TIME: case SvNumFormatType::DATETIME: + case SvNumFormatType::DURATION: nRetIndexExpr = nFuncFmtIndex; break; default: @@ -4547,13 +4548,26 @@ StackVar ScInterpreter::Interpret() // unnecessarily duplicate the information. if (pCur->GetDoubleType() != 0) { - const double fVal = PopDouble(); + double fVal = PopDouble(); if (!bForcedResultType) { if (nCurFmtType != nFuncFmtType) nRetIndexExpr = 0; // carry format index only for matching type nRetTypeExpr = nFuncFmtType = nCurFmtType; } + if (nRetTypeExpr == SvNumFormatType::DURATION) + { + // Round the duration in case a wall clock time + // display format is used instead of a duration + // format. To micro seconds which then catches + // the converted hh:mm:ss.9999997 cases. + if (fVal != 0.0) + { + fVal *= 86400.0; + fVal = rtl::math::round( fVal, 6); + fVal /= 86400.0; + } + } PushTempToken( CreateFormulaDoubleToken( fVal)); } if ( nFuncFmtType == SvNumFormatType::UNDEFINED ) @@ -4663,6 +4677,11 @@ StackVar ScInterpreter::Interpret() else nRetFmtType = SvNumFormatType::NUMBER; + // Currently (2019-05-06) nothing else can cope with a duration format + // type, change to time as it was before. + if (nRetFmtType == SvNumFormatType::DURATION) + nRetFmtType = SvNumFormatType::TIME; + if (nGlobalError != FormulaError::NONE && GetStackType() != svError ) PushError( nGlobalError); diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index b18ddd7fb673..aefb26c920e3 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -1129,15 +1129,16 @@ ScMatrixRef ScInterpreter::MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef return xResMat; } -// for DATE, TIME, DATETIME +// for DATE, TIME, DATETIME, DURATION static void lcl_GetDiffDateTimeFmtType( SvNumFormatType& nFuncFmt, SvNumFormatType nFmt1, SvNumFormatType nFmt2 ) { if ( nFmt1 != SvNumFormatType::UNDEFINED || nFmt2 != SvNumFormatType::UNDEFINED ) { if ( nFmt1 == nFmt2 ) { - if ( nFmt1 == SvNumFormatType::TIME || nFmt1 == SvNumFormatType::DATETIME ) - nFuncFmt = SvNumFormatType::TIME; // times result in time + if ( nFmt1 == SvNumFormatType::TIME || nFmt1 == SvNumFormatType::DATETIME + || nFmt1 == SvNumFormatType::DURATION ) + nFuncFmt = SvNumFormatType::DURATION; // times result in time duration // else: nothing special, number (date - date := days) } else if ( nFmt1 == SvNumFormatType::UNDEFINED ) @@ -1181,6 +1182,7 @@ void ScInterpreter::CalculateAddSub(bool _bSub) case SvNumFormatType::DATE : case SvNumFormatType::TIME : case SvNumFormatType::DATETIME : + case SvNumFormatType::DURATION : nFmt2 = nCurFmtType; break; case SvNumFormatType::CURRENCY : @@ -1203,6 +1205,7 @@ void ScInterpreter::CalculateAddSub(bool _bSub) case SvNumFormatType::DATE : case SvNumFormatType::TIME : case SvNumFormatType::DATETIME : + case SvNumFormatType::DURATION : nFmt1 = nCurFmtType; break; case SvNumFormatType::CURRENCY : |