Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#39 Error in rount_t_up

Minor
closed
nobody
None
5
2012-07-20
2001-12-13
Anonymous
No

There is an error in both the function round_t_down
and rount_t_up in the file web/functions.inc.

Basicly the function involves any time that
$resolution is an odd amount. The issue is if the
start of the day, if that time is not an invterval of
the $resolution, starting from Jan 1, 1970 (start of
unix time, i think).

To fix this, you add an extra paramater to these calls
which accepts $am7, the start of the day time.

The new function are as follows:

function round_t_down($t, $resolution, $am7)
{
return (int)$t - (int)abs(((int)$t-(int)$am7)
% $resolution);

}

function round_t_up2($t, $resolution, $am7)
{

if (($t-$am7) % $resolution != 0)
{
return $t + $resolution - abs(((int)$t-(int)
$am7) % $resolution);
}
else
{
return $t;
}

}

These probably could be cleaned up a little (don't
know if you need all the casting, but it works.

Discussion

  • Daniel
    Daniel
    2002-05-18

    Logged In: YES
    user_id=29285

    applied to CVS

     


Anonymous


Cancel   Add attachments