summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-16 15:40:52 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-01-17 08:37:39 +0100
commitbd29365d224ff1d34d4130703ddf8a33e487b6af (patch)
tree74e36b1370074320f21b78f5fe266ffcba6a914c /i18npool
parentcc9e89816f8193989ea4ee5bfd9b1c39b196b5e7 (diff)
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 <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/calendar_hijri.hxx2
-rw-r--r--i18npool/source/calendar/calendar_hijri.cxx15
2 files changed, 8 insertions, 9 deletions
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;
}
}