[Libreoffice-commits] .: 2 commits - sax/qa sax/source

Michael Stahl mst at kemper.freedesktop.org
Wed Feb 29 05:11:42 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 0d9757e43217929fa172c1feecd161873cd7019b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Feb 29 14:08:17 2012 +0100

    sax: ConverterTest: add leap year tests

diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index 64bbf29..4a3d364 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(99, 59, 59, 23, 31, 12, 9999),
             "9999-12-31T23:59:59.9999999999999999999999999999999999999Z",
             "9999-12-31T23:59:59.99" );
+    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" );
     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"*/ );
@@ -240,6 +244,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");
 }
 
commit 3c993bd0c3120445f27cb37e6ecfd8b45c6605e0
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>

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index eb8cc74..95f6494 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -1304,7 +1304,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