Re: [PATCH] Fix for bug #19788
| From: | Monte Ohrt | Date: | Sun, 03 Nov 2002 22:31:27 +0000 |
| Subject: | Re: [PATCH] Fix for bug #19788 | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-10463@lists.php.net to get a copy of this message | ||
mktime() is not safe with dates pre 1970 and post 2038. That is why it is calculated manually.
Monte
Ilia A. wrote:
Attached is a fix for bug #19788. This is also a more accurate and quite likely faster implementation of the original code. Ilia P.S. Please cc your replies to me, since I am not subscribed to the list. ------------------------------------------------------------------------ Index: Calc.php =================================================================== RCS file: /repository/pear/Date/Date/Calc.php,v retrieving revision 1.2 diff -u -3 -p -r1.2 Calc.php --- Calc.php 18 Sep 2002 14:54:07 -0000 1.2 +++ Calc.php 3 Nov 2002 19:25:17 -0000 @@ -182,22 +182,9 @@ class Date_Calcif(empty($day)) $day = Date_Calc::dateNow("%d");- if($month > 2) - $month -= 2; - else - { - $month += 10; - $year--; - }-- $day = ( floor((13 * $month - 1) / 5) + - $day + ($year % 100) + - floor(($year % 100) / 4) + - floor(($year / 100) / 4) - 2 * - floor($year / 100) + 77);-- $weekday_number = (($day - 7 * floor($day / 7)));-+ $time_s = mktime(0, 0, 0, $month, $day, $year); + $weekday_number = date("W", $time_s); + return $weekday_number;} // end func dayOfWeek