Kaydet (Commit) e055b4a0 authored tarafından Eike Rathke's avatar Eike Rathke

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/59719Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: Jenkins
üst a19161a8
......@@ -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;
......
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment