RE: [PEAR-DEV] fix fo Bug #19788 (Date_Calc::weekOfYear() functio n problem)
| From: | LIMBOURG Arnaud | Date: | Wed, 27 Nov 2002 08:40:09 +0000 |
| Subject: | RE: [PEAR-DEV] fix fo Bug #19788 (Date_Calc::weekOfYear() functio n problem) | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-11153@lists.php.net to get a copy of this message | ||
Could you post a unified (diff -u), please, it is more readable.
Arnaud.
> related to http://bugs.php.net/bug.php?id=19788
>
> I've found out, that there is a leap year calculation error in
> /repository/pear/Date/Date/Calp.php and that's my fix:
>
> Index: Calc.php
> ===================================================================
> RCS file: /repository/pear/Date/Date/Calc.php,v
> retrieving revision 1.4
> diff -r1.4 Calc.php
> 236,242c236,246
> < $week_year = $year - 1501;
> < $week_day = $week_year * 365 + floor($week_year /
> 4) - 29872 + 1
> < - floor($week_year / 100) + floor(($week_year -
> 300) / 400);
> <
> < $week_number =
> ceil((Date_Calc::julianDate($day,$month,$year)
> < + floor(($week_day + 4) % 7)) / 7);
> <
> ---
> > $days = 0;
> > for($this_year = 1501; $this_year < $year; $this_year++) {
> > $leap_year = false;
> > if ($this_year % 4 == 0) $leap_year = true;
> > if ($this_year % 100 == 0) $leap_year = false;
> > if ($this_year % 400 == 0) $leap_year = true;
> > $days += ($leap_year) ? 366 : 365;
> > }
> >
> > $week_number = ceil((Date_Calc::julianDate($day,
> $month, $year) -
> (($days + 2) % 7))/7) + 1;
> >
>
> Please test it again (see test script on
> http://bugs.php.net/bug.php?id=19788), commit it and close the
> bug.
>
> Regards, Kai
>
> P.S.: I have only doc karma
>
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>