On Tue, Feb 28, 2012 at 10:10:10PM -0500, Kohei Yoshida wrote:
From 0666b5dca1a210ce7abc61a522a59c48661fe664 Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@suse.com>
Date: Tue, 28 Feb 2012 22:01:52 -0500
Subject: [PATCH] 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.
---
 sax/source/tools/converter.cxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
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
OK for master, libreoffice-3-5, libreoffice-3-5-1.
It seems to me that what was originally intended was:
   return ((nYear % 4) == 0)
       &&  ( !((nYear % 100) == 0) || ((nYear % 400) == 0) );
That is, the bug is an switch of parenthesis and negation. Your
version is strictly equivalent and maybe a bit more readable, so good
to go.
-- 
Lionel
Context
   
 
  Privacy Policy |
  
Impressum (Legal Info) |
  
Copyright information: Unless otherwise specified, all text and images
  on this website are licensed under the
  
Creative Commons Attribution-Share Alike 3.0 License.
  This does not include the source code of LibreOffice, which is
  licensed under the Mozilla Public License (
MPLv2).
  "LibreOffice" and "The Document Foundation" are
  registered trademarks of their corresponding registered owners or are
  in actual use as trademarks in one or more countries. Their respective
  logos and icons are also subject to international copyright laws. Use
  thereof is explained in our 
trademark policy.