[kronolith] Kronolith CVS: gregoriantojd not found

Michael Cochrane mike@graftonhall.co.nz
Sat, 8 Dec 2001 02:26:13 +0000


Yes we can :-) He's a different algorithm... a bit slower as more comparisons 
and calculations involved but gives the same result...

Index: kronolith/lib/Kronolith.php
===================================================================
RCS file: /repository/kronolith/lib/Kronolith.php,v
retrieving revision 1.44
diff -r1.44 Kronolith.php
192,197c192,214
<         
<         $J = gregoriantojd($month, $day, $year);
<         $d = ($J + 31741 - ($J % 7)) % 146097 % 36524 % 1461;
<         $L = floor($d / 1460); 
<         $correctedDayInYear = (($d - $L) % 365) + $L;
<         return floor($correctedDayInYear / 7) + 1;   
---
> 
>         $dayOfYear = Kronolith::dayOfYear($year,$month,$day);
>         $dayOfWeek = Kronolith::dayOfWeek($year,$month,$day);
>         $dayOfWeekJan1 = Kronolith::dayOfWeek($year,1,1);
> 
>         if ($dayOfYear <= 7-$dayOfWeekJan1 && $dayOfWeekJan1 > 3 ) {
>              if ($dayOfWeekJan1 == 4 || ($dayOfWeekJan1 == 5 && 
Kronolith::isLeapYear($year-1)))
>                   return "53";
>              else
>                   return "52";
>         }
> 
>         if (Kronolith::isLeapYear($year))
>             $daysInYear = 366;
>         else
>             $daysInYear = 365;
> 
>         if ($daysInYear - $dayOfYear < 3 - $dayOfWeek) return "1";
> 
>         $WeekNumber = floor(($dayOfYear + (6 - $dayOfWeek) + 
$dayOfWeekJan1) / 7);
>         if ($dayOfWeekJan1 > 3) { $WeekNumber -= 1; }
> 
>         return $WeekNumber;

Quoting Jan Schneider <jan@horde.org>:

> 
> Hm, we changed the way to calculate the week number because the old way 
> didn't work with windows. But we can change the code to not depend on the 
> Gregorian functions from the calendar library.
> 
> Jan.
> 
> ::::::::::::::::::::::::::::::::::::::::
> AMMMa AG - discover your knowledge
> :::::::::::::::::::::::::::
> Detmolder Str. 25-33 :: D-33604 Bielefeld
> fon +49.521.96878-0 :: fax  +49.521.96878-20
> http://www.ammma.de
> ::::::::::::::::::::::::::::::::::::::::::::::
> 
> -- 
> Kronolith mailing list: http://horde.org/kronolith/
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: kronolith-unsubscribe@lists.horde.org
> 
>