CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Time calc

Print topic Send  topic

Author Message
Ron Borkent
Posted: 02/03/2002, 1:29 AM

Oke, I've been chopping away at this for 2 days now and close to a breakdown ;-)

I have to do some math with times. The situation is this:

there is a timeslot, lets say from 06:00($a) 'till 14:00($b) that pays a 25% bonus. A worker worked from 5:00($van) 'till 15:00($tot).The result is printed in a field($veld).
This is just an example, there are several timeslots and the time worked can diver to. Here's the function I wrote:

function time_diff($van,$tot,$a,$b)
{

if(($van >= $a) && ($tot <= $b))
{
$veld ='1';//($tot -$van) /60 /60;
}
elseif(($van <= $a) && ($tot <= $b)&& ($tot > $a))
{
$veld =( $tot -$a)/60 /60;
}
elseif(( $van >= $a) && ($tot > $b)&& ($van < $b))
{
$veld='3';//($b - $van)/60 /60;
}
elseif(($van < $a )&&( $tot >= $b))
{
$veld='4';//($b-$a)/60 /60 ;
}
return $veld;
}

All variables are converted to timestamps with strtotime(). The problems I have is with timeslots that end with 00:00 I get values even when $van $tot do not even come near to the timeslot.

I suck at math so if somebody could help?

Nicole
Posted: 02/04/2002, 7:04 AM

Ron,
not clear enough for me... Do you mean the situation when $tot= 00:00? If so I suppose you should first compare the value to "00:00" string and change it to 24:00 if they are the same. After it convert string to time.
Ron Borkent
Posted: 02/05/2002, 12:58 AM

Thnx Nicole, I had thought of that but it somehow doesn't work. It goes beserk when you use 24:00 as a time. I now convert $van to 00:00:01 and $tot to 23:59:59 when the user fills in 00:00 and then use round to get nice looking results :-) It wont win any proces I'm sure but it does the trick.

Ron

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.