[geeklog-cvs] geeklog: Fixed isLeapYear() bug

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Jun 8 19:37:05 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/0e32d93126e5
changeset: 7092:0e32d93126e5
user:      Sean Clark <sc1245 at messiah.edu>
date:      Mon Jun 08 19:35:00 2009 -0400
description:
Fixed isLeapYear() bug

diffstat:

 system/classes/calendar.class.php |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r 3bfab85d3b7c -r 0e32d93126e5 system/classes/calendar.class.php
--- a/system/classes/calendar.class.php	Sun Jun 07 22:12:33 2009 +0200
+++ b/system/classes/calendar.class.php	Mon Jun 08 19:35:00 2009 -0400
@@ -177,7 +177,7 @@
     */
     function getDayOfWeek($day = 1, $month = 1, $year = '')
     {
-	    if (empty($year)) {
+        if (empty($year)) {
             $year = $this->_default_year;
         }
 
@@ -225,7 +225,14 @@
             $year = $this->_default_year;
         }
 
-        if (round(($year - 2000)/4) == (($year - 2000)/4)){
+        if (($year % 4) == 0) {
+            if (($year % 100) == 0) {
+                if (($year % 400) == 0) {
+                    return 1;
+                } else {
+                    return 0;
+                }
+            }
             return 1;
         } else {
             return 0;
@@ -351,8 +358,8 @@
     */
     function getMonthName($month = 1)
     {
-	$month = $month - 1;
-	if (empty($this->_lang_months)) $this->setLanguage();
+    $month = $month - 1;
+    if (empty($this->_lang_months)) $this->setLanguage();
 
         switch ($month) {
         case 0:
@@ -485,7 +492,7 @@
                 } else {
                     $cur_day = new CalendarDay();
                     $cur_day->year = $year;
-                    $cur_day->daynumber = $nextday; 
+                    $cur_day->daynumber = $nextday;     
                     $week[$aw][$wd] = $cur_day;
 
                     // Bail if we just printed last day



More information about the geeklog-cvs mailing list