[Libreoffice-commits] core.git: 2 commits - sc/source tools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Aug 28 17:50:30 UTC 2018


 sc/source/core/data/dpgroup.cxx |   16 +++++++---------
 sc/source/core/data/dputil.cxx  |   13 +++++++------
 tools/source/datetime/ttime.cxx |    1 +
 3 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit e055b4a0fc23e1d0ad5d498f9195790dd41f6b3e
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Tue Aug 28 16:59:26 2018 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Tue Aug 28 19:50:15 2018 +0200

    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 at redhat.com>
    Tested-by: Jenkins

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;
         }
     }
commit a19161a8b17a607f9d4a92c4ea57bafd55087841
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Tue Aug 28 17:13:05 2018 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Tue Aug 28 19:50:04 2018 +0200

    Assign fFractionOfSecond in shortcut
    
    Otherwise it may be uninitialized.
    
    Change-Id: Iccb61d66c8410ac8ecdabbd96204d2393060bc1d
    Reviewed-on: https://gerrit.libreoffice.org/59721
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index d9bfc40dfc02..f1dea02a6afb 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -287,6 +287,7 @@ void tools::Time::GetClock( double fTimeInDays,
     if (fTime <= 0.0 || fTime >= 1.0)
     {
         nHour = nMinute = nSecond = 0;
+        fFractionOfSecond = 0.0;
         return;
     }
 


More information about the Libreoffice-commits mailing list