#52 Problem with adodb-time

Next_Version
closed-accepted
5
2006-08-23
2006-08-17
jgarces
No

Hello

I have a problem with adodb_mktime in
adodb-time.inc.php. Create a new time with 24 months 1
day and 1999 year:

$t = adodb_mktime(0, 0, 0, 24, 1, 1999, false, false);
echo adodb_date("Y-m-d H:i:s", $t);

Result: 01-01-2001
Expected Result: 01-12-2000

The problem is in month calculation, line 1144:

if ($mon > 12) {
$y = floor($mon / 12);
$year += $y;
$mon -= $y*12;
} else if ($mon < 1) { <------- Line 1144
$y = ceil((1-$mon) / 12);
$year -= $y;
$mon += $y*12;
}

$mon = 0 if $mon = 24.

I changed to:

if ($mon > 12) {
$y = floor($mon / 12);
$year += $y;
$mon -= $y*12;
}

if ($mon < 1) {
$y = ceil((1-$mon) / 12);
$year -= $y;
$mon += $y*12;
}

Delete "else".

Check please, Thanks.

Discussion

  • Mark Dickenson

    Mark Dickenson - 2006-08-23

    Logged In: YES
    user_id=752816

    I have added the fix to the next version.

    Thanks :)

     
  • Mark Dickenson

    Mark Dickenson - 2006-08-23
    • milestone: --> Next_Version
    • status: open --> closed-accepted
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks