summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-08-28 16:59:26 +0200
committerEike Rathke <erack@redhat.com>2018-08-28 19:50:15 +0200
commite055b4a0fc23e1d0ad5d498f9195790dd41f6b3e (patch)
treea72d6e711027348b4aef0447675c242f2b046b53 /sc
parenta19161a8b17a607f9d4a92c4ea57bafd55087841 (diff)
Use tools::Time::GetClock() to obtain hour,minute,second
... instead of rtl::math::approxFloor(fValue*DATE_TIME_FACTOR+0.5) seconds that most times works but sometimes not. Change-Id: Iaca69630461f2067622898fab35cda61d20172a9 Reviewed-on: https://gerrit.libreoffice.org/59719 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/dpgroup.cxx16
-rw-r--r--sc/source/core/data/dputil.cxx13
2 files changed, 14 insertions, 15 deletions
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 70b326b8c5a7..92a6810d968d 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -169,31 +169,29 @@ bool ScDPGroupDateFilter::match( const ScDPItemData & rCellData ) const
nGroupType == DataPilotFieldGroupBy::SECONDS)
{
// handle time
- // (as in the cell functions, ScInterpreter::ScGetHour etc.: seconds are rounded)
+ // (do as in the cell functions, ScInterpreter::ScGetHour() etc.)
- double time = rCellData.GetValue() - approxFloor(rCellData.GetValue());
- long seconds = static_cast<long>(approxFloor(time*DATE_TIME_FACTOR + 0.5));
+ sal_uInt16 nHour, nMinute, nSecond;
+ double fFractionOfSecond;
+ tools::Time::GetClock( rCellData.GetValue(), nHour, nMinute, nSecond, fFractionOfSecond, 0);
switch (nGroupType)
{
case DataPilotFieldGroupBy::HOURS:
{
- sal_Int32 hrs = seconds / 3600;
- if (hrs == nValue)
+ if (nHour == nValue)
return true;
}
break;
case DataPilotFieldGroupBy::MINUTES:
{
- sal_Int32 minutes = (seconds % 3600) / 60;
- if (minutes == nValue)
+ if (nMinute == nValue)
return true;
}
break;
case DataPilotFieldGroupBy::SECONDS:
{
- sal_Int32 sec = seconds % 60;
- if (sec == nValue)
+ if (nSecond == nValue)
return true;
}
break;
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index 6afdc101a006..aefa1e143bcb 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -314,21 +314,22 @@ sal_Int32 ScDPUtil::getDatePartValue(
nDatePart == sheet::DataPilotFieldGroupBy::SECONDS)
{
// handle time
- // (as in the cell functions, ScInterpreter::ScGetHour etc.: seconds are rounded)
+ // (do as in the cell functions, ScInterpreter::ScGetHour() etc.)
- double fTime = fValue - rtl::math::approxFloor(fValue);
- long nSeconds = static_cast<long>(rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5));
+ sal_uInt16 nHour, nMinute, nSecond;
+ double fFractionOfSecond;
+ tools::Time::GetClock( fValue, nHour, nMinute, nSecond, fFractionOfSecond, 0);
switch (nDatePart)
{
case sheet::DataPilotFieldGroupBy::HOURS:
- nResult = nSeconds / 3600;
+ nResult = nHour;
break;
case sheet::DataPilotFieldGroupBy::MINUTES:
- nResult = ( nSeconds % 3600 ) / 60;
+ nResult = nMinute;
break;
case sheet::DataPilotFieldGroupBy::SECONDS:
- nResult = nSeconds % 60;
+ nResult = nSecond;
break;
}
}