[Libreoffice-commits] core.git: writerfilter/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Sat Jul 3 19:05:06 UTC 2021


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

New commits:
commit e732bbacbf33a3d0c08fb96a18072e5b1ca46691
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Jul 3 19:28:36 2021 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Jul 3 21:04:35 2021 +0200

    Simplify lcl_dateTimeFromSerial
    
    Change-Id: Ifa237cde581c9b89956db104db9f87a901f84d72
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118306
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 75812194a12d..881c512358d8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6431,27 +6431,12 @@ void DomainMapper_Impl::AppendFieldResult(std::u16string_view rString)
     pContext->AppendResult(rString);
 }
 
-// Calculates css::DateTime based on ddddd.sssss since 1900-1-0
+// Calculates css::DateTime based on ddddd.sssss since 1899-12-30
 static util::DateTime lcl_dateTimeFromSerial(const double& dSerial)
 {
-    const sal_uInt32 secondsPerDay = 86400;
-    const sal_uInt16 secondsPerHour = 3600;
-
     DateTime d(Date(30, 12, 1899));
-    d.AddDays( static_cast<sal_Int32>(dSerial) );
-
-    double frac = std::modf(dSerial, &o3tl::temporary(double()));
-    sal_uInt32 seconds = frac * secondsPerDay;
-
-    util::DateTime date;
-    date.Year = d.GetYear();
-    date.Month = d.GetMonth();
-    date.Day = d.GetDay();
-    date.Hours = seconds / secondsPerHour;
-    date.Minutes = (seconds % secondsPerHour) / 60;
-    date.Seconds = seconds % 60;
-
-    return date;
+    d.AddTime(dSerial);
+    return d.GetUNODateTime();
 }
 
 void DomainMapper_Impl::SetFieldResult(OUString const& rResult)


More information about the Libreoffice-commits mailing list