i18npool/inc/calendar_hijri.hxx             |    2 +-
 i18npool/source/calendar/calendar_hijri.cxx |   15 +++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)

New commits:
commit bd29365d224ff1d34d4130703ddf8a33e487b6af
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Tue Jan 16 15:40:52 2018 +0100

    Calendar_hijri::getJulianDay can just as well return sal_Int32
    
    ...instead of converting from sal_Int32 to double and back to sal_Int32
    
    Change-Id: I005777ff031dbbd919d46c971a84dff17f0adf9b
    Reviewed-on: https://gerrit.libreoffice.org/47997
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/i18npool/inc/calendar_hijri.hxx b/i18npool/inc/calendar_hijri.hxx
index 31e2fc6d6bfc..240cc7b20095 100644
--- a/i18npool/inc/calendar_hijri.hxx
+++ b/i18npool/inc/calendar_hijri.hxx
@@ -67,7 +67,7 @@ private:
     static void getHijri(sal_Int32 *day, sal_Int32 *month, sal_Int32 *year);
     static void ToGregorian(sal_Int32 *day, sal_Int32 *month, sal_Int32 *year);
     static void getGregorianDay(sal_Int32 jd, sal_Int32 *pnDay, sal_Int32 
*pnMonth, sal_Int32 *pnYear);
-    static double getJulianDay(sal_Int32 day, sal_Int32 month, sal_Int32 year);
+    static sal_Int32 getJulianDay(sal_Int32 day, sal_Int32 month, sal_Int32 
year);
 };
 
 }
diff --git a/i18npool/source/calendar/calendar_hijri.cxx 
b/i18npool/source/calendar/calendar_hijri.cxx
index 34586a482557..064d04e6d4d6 100644
--- a/i18npool/source/calendar/calendar_hijri.cxx
+++ b/i18npool/source/calendar/calendar_hijri.cxx
@@ -176,17 +176,16 @@ Calendar_hijri::getHijri(sal_Int32 *day, sal_Int32 
*month, sal_Int32 *year)
     sal_Int32 syndiff;
     sal_Int32 newsyn;
     double newjd;
-    double julday;
     sal_Int32 synmonth;
 
     // Get Julian Day from Gregorian
-    julday = getJulianDay(*day, *month, *year);
+    sal_Int32 const julday = getJulianDay(*day, *month, *year);
 
     // obtain approx. of how many Synodic months since the beginning of the 
year 1900
     synmonth = static_cast<sal_Int32>(0.5 + (julday - jd1900)/SynPeriod);
 
     newsyn = synmonth;
-    prevday = static_cast<sal_Int32>(julday) - 0.5;
+    prevday = julday - 0.5;
 
     do {
         newjd = NewMoon(newsyn);
@@ -200,7 +199,7 @@ Calendar_hijri::getHijri(sal_Int32 *day, sal_Int32 *month, 
sal_Int32 *year)
     syndiff = newsyn - SynRef;
 
     // Round up the day
-    *day = static_cast<sal_Int32>(static_cast<sal_Int32>(julday) - newjd + 
0.5);
+    *day = static_cast<sal_Int32>(julday - newjd + 0.5);
     *month =  (syndiff % 12) + 1;
 
     // currently not supported
@@ -293,17 +292,17 @@ Calendar_hijri::getGregorianDay(sal_Int32 lJulianDay, 
sal_Int32 *pnDay, sal_Int3
         (*pnYear)--;
 }
 
-double
+sal_Int32
 Calendar_hijri::getJulianDay(sal_Int32 day, sal_Int32 month, sal_Int32 year)
 {
     double jy, jm;
 
     if( year == 0 ) {
-    return -1.0;
+    return -1;
     }
 
     if( year == 1582 && month == 10 && day > 4 && day < 15 ) {
-    return -1.0;
+    return -1;
     }
 
     if( month > 2 ) {
@@ -325,7 +324,7 @@ Calendar_hijri::getJulianDay(sal_Int32 day, sal_Int32 
month, sal_Int32 year)
         intgr += static_cast<sal_Int32>(2 - ja + static_cast<sal_Int32>(0.25 * 
ja));
     }
 
-    return static_cast<double>(intgr);
+    return intgr;
 }
 
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to