[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 2 commits - sax/qa sax/source

Michael Stahl mst at kemper.freedesktop.org
Wed Feb 29 05:29:15 PST 2012


 sax/qa/cppunit/test_converter.cxx |    6 ++++++
 sax/source/tools/converter.cxx    |    2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit eebc3e941131ffb09439f69313e697e0ed660135
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Feb 29 14:08:17 2012 +0100

    sax: ConverterTest: add leap year tests
    
    (cherry picked from commit 0d9757e43217929fa172c1feecd161873cd7019b)
    
    Signed-off-by: Eike Rathke <erack at redhat.com>

diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index dcd5bb7..4e3a56f 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -212,6 +212,10 @@ void ConverterTest::testDateTime()
     doTest( util::DateTime(0, 0, 0, 24, 1, 1, 333)
                 /*(0, 0, 0, 0, 2, 1, 333)*/,
             "0333-01-01T24:00:00"/*, "0333-01-02T00:00:00"*/ );
+    doTest( util::DateTime(0, 0, 0, 0, 29, 2, 2000), // leap year
+            "2000-02-29T00:00:00-00:00", "2000-02-29T00:00:00" );
+    doTest( util::DateTime(0, 0, 0, 0, 29, 2, 1600), // leap year
+            "1600-02-29T00:00:00-00:00", "1600-02-29T00:00:00" );
     doTestDateTimeF( "+0001-01-01T00:00:00" ); // invalid: ^+
     doTestDateTimeF( "1-01-01T00:00:00" ); // invalid: < 4 Y
     doTestDateTimeF( "0001-1-01T00:00:00" ); // invalid: < 2 M
@@ -234,6 +238,8 @@ void ConverterTest::testDateTime()
     doTestDateTimeF( "0001-01-02T00:00:00+14:01" ); // invalid: TZ > +14:00
     doTestDateTimeF( "0001-01-02T00:00:00-15:00" ); // invalid: TZ < -14:00
     doTestDateTimeF( "0001-01-02T00:00:00-14:01" ); // invalid: TZ < -14:00
+    doTestDateTimeF( "2100-02-29T00:00:00-00:00" ); // invalid: no leap year
+    doTestDateTimeF( "1900-02-29T00:00:00-00:00" ); // invalid: no leap year
     OSL_TRACE("\nSAX CONVERTER TEST END\n");
 }
 
commit ff47b3717ca8bc561917c8ad5cd8bb5749638270
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 28 22:01:52 2012 -0500

    Correctly calculate leap year.
    
    With the old code, year 2000 would not be a leap year, but it actually
    is.  With this, Calc correctly loads cell with date value of 2000-2-29.
    
    (regression from CWS sw33bf02 8786083eb9dabb0d7b328a217ba99a1d71493ad7)
    
    Signed-off-by: Stephan Bergmann <sbergman at redhat.com>
    Signed-off-by: Eike Rathke <erack at redhat.com>
    Signed-off-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 3c993bd0c3120445f27cb37e6ecfd8b45c6605e0)

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 74d056c..0414297 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -1154,7 +1154,7 @@ readDateTimeComponent(const ::rtl::OUString & rString,
 static bool lcl_isLeapYear(const sal_uInt32 nYear)
 {
     return ((nYear % 4) == 0)
-        && !(((nYear % 100) == 0) || ((nYear % 400) == 0));
+        && (((nYear % 100) != 0) || ((nYear % 400) == 0));
 }
 
 static sal_uInt16


More information about the Libreoffice-commits mailing list