How to go more precise ?

How to go more precise ?

am 21.06.2008 23:44:33 von Eric Lee

------=_NextPart_000_095E_01C8D42B.0C7C3CD0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable

hi,=20

I'am writing a small function that calc how long estimate from day to =
day.
But that isn't so precise.=20

Any example for this ?

function range($period /* $start_time, $end_time */)
{
=20
/* version 2*/
static $time_num =3D array(
'h' =3D> 60,
'd' =3D> 24,
'w' =3D> 7,
'm' =3D> 4,
'y' =3D> 12,
);

static $time_unit =3D array(
'h' =3D> 'Hours',
'd' =3D> 'Days',
'w' =3D> 'Weeks',
'm' =3D> 'Month',
'y' =3D> 'Years',
);

/* convert to base unit to minute */
$period =3D $period / 60;
=20
/* version 2*/
$type =3D '';
foreach ($time_num as $key =3D> $value)
{
if ($period > $value)
{
$period =3D $period / $value;
$type =3D $key;
}
else
break;
}
=20
return $period . ' ' . format_string($type);
}

function format_string($unit)
{
/* version 2*/
=20
static $time_unit =3D array(
'h' =3D> 'Hours',
'd' =3D> 'Days',
'w' =3D> 'Weeks',
'm' =3D> 'Month',
'y' =3D> 'Years',
);
=20
return isset($time_unit[$unit]) ? $time_unit[$unit] : $type;
}

Thanks
Regards,
Eric,

----------------------------------------------------
http://myprojects.srhost.info
eric{at}myprojects{dot}srhost{dot}info
------=_NextPart_000_095E_01C8D42B.0C7C3CD0--