summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}
}