ID:               28344
 Updated by:       [EMAIL PROTECTED]
 Reported By:      powerstat at web dot de
-Status:           Open
+Status:           Feedback
-Bug Type:         Unknown/Other Function
+Bug Type:         Date/time related
 Operating System: RedHat AS 2.1 IA64
 PHP Version:      4.3.6
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2004-05-10 09:19:19] powerstat at web dot de

Description:
------------
PHP has a function called mktime()
(see http://www.php.net/manual/en/function.mktime.php)
this uses internally the Unix/Linux mktime() function.

We detected the problem within the phpGroupWare
(actual cvs checkout from branch 0.9.16)

www.phpgroupware.org 
cvs repositories:
https://savannah.gnu.org/projects/phpgwapi
and
https://savannah.gnu.org/projects/phpgroupware/
 

The bug itself will occur in the following file: 
http://savannah.gnu.org/cgi-bin/viewcvs/phpgwapi/phpgwapi/inc/class.datetime.inc.php?rev=1.5.2.12.2.8&content-type=text/vnd.viewcvs-markup

in the method 

function get_weekday_start($year,$month,$day)

when php mktime() will be called, the result (in seconds) will be off
by 2 days. This happens especially when zero or negative day values
will be used.
These values are allowed by php mktime() as well as by the underlying
unix mktime()
(see Itanium man mktime).

We found that the problem only occurs in the above file,
using the same values in a small test script will give backe the
correct results!

We assume that it might be a memory/stack problem within php itself,
that we are not able to track down.


Reproduce code:
---------------
For URLs see description.

switch($weekday)
{
  case 0:
    $sday = mktime(2,0,0,$month,$day - 6,$year);
    break;
  case 1:
    $sday = mktime(2,0,0,$month,$day,$year);
    break;
  default:
    $sday = mktime(2,0,0,$month,$day - ($weekday - 1),$year);
    echo ':' . $day . ':' . $weekday . "<br />\n";
    echo ':' . $year . '/' . $month . '/' . ($day - ($weekday - 1)) . '
: ' . $sday . ":<br /><hr />\n";
}


Expected result:
----------------
The correct value in seconds (differs a bit by tomezone settings), but
not values that are 2 days or more off.

orrect Output values here 32bit linux machine:
 
:1:4
:2004/4/-2 : 1080518400:
:1:2
:2004/6/0 : 1085961600:
:1:6
:2004/05/-4 : 1082937600:
:1:6
:2004/05/-4 : 1082937600:


wrong output values 64 bit itanium2:
 
:1:4
:2004/4/-2 : 1080694800:
:1:2
:2004/6/0 : 1085965200:
:1:6
:2004/05/-4 : 1083286800:
:1:6
:2004/05/-4 : 1083286800:




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28344&edit=1

Reply via email to