[Libreoffice-commits] core.git: Branch 'libreoffice-4-0-2' - i18npool/source

Eike Rathke erack at redhat.com
Tue Mar 26 02:26:57 PDT 2013


 i18npool/source/calendar/calendar_gregorian.cxx |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 7d7c4aa9f07e309e9185bab77a197b3dbe1f2dd1
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Mar 25 21:21:41 2013 +0100

    resolved fdo#44286 some historical dates were decremented
    
    Depending on historical timezone data with odd offsets some historical
    dates were decremented by one day due to a rounding error.
    
    Change-Id: I3216b1c043fe5ab9035a558031f1a58efa0c3b3d
    (cherry picked from commit 6013fe19a40dd16ce435a2428f7405b51930689e)
    Reviewed-on: https://gerrit.libreoffice.org/3037
    Reviewed-by: Thorsten Behrens <tbehrens at suse.com>
    Tested-by: Thorsten Behrens <tbehrens at suse.com>
    Reviewed-by: Petr Mladek <pmladek at suse.cz>
    Tested-by: Petr Mladek <pmladek at suse.cz>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index a2a5324..e01abaf 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/i18n/reservedWords.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <comphelper/processfactory.hxx>
+#include <rtl/math.hxx>
 
 #include <stdio.h>
 #include <string.h>
@@ -283,8 +284,19 @@ Calendar_gregorian::getUniqueID() throw(RuntimeException)
 void SAL_CALL
 Calendar_gregorian::setDateTime( double timeInDays ) throw(RuntimeException)
 {
+        // ICU handles dates in milliseconds as double values and uses floor()
+        // to obtain integer values, which may yield a date decremented by one
+        // for odd (historical) timezone values where the computed value due to
+        // rounding errors has a fractional part in milliseconds. Ensure we
+        // pass a value without fraction here. If not, that may lead to
+        // fdo#44286 or fdo#52619 and the like, e.g. when passing
+        // -2136315212000.000244 instead of -2136315212000.000000
+        double fM = timeInDays * U_MILLIS_PER_DAY;
+        double fR = rtl::math::round( fM );
+        SAL_INFO_IF( fM != fR, "i18npool",
+                "Calendar_gregorian::setDateTime: " << std::fixed << fM << " rounded to " << fR);
         UErrorCode status;
-        body->setTime(timeInDays * U_MILLIS_PER_DAY, status = U_ZERO_ERROR);
+        body->setTime( fR, status = U_ZERO_ERROR);
         if ( !U_SUCCESS(status) ) throw ERROR;
         getValue();
 }
@@ -679,6 +691,11 @@ void Calendar_gregorian::setValue() throw(RuntimeException)
                     DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
                     DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
                 }
+                SAL_INFO( "i18npool", "Calendar_gregorian::setValue:" <<
+                        "  nZone0 " << nZone0 << ", nDST0 " << nDST0 <<
+                        ", nZone1 " << nZone1 << ", nDST1 " << nDST1 <<
+                        ", nZone2 " << nZone2 << ", nDST2 " << nDST2 <<
+                        ", nZone3 " << nZone3 << ", nDST3 " << nDST3);
             }
         }
 #if erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR


More information about the Libreoffice-commits mailing list