Re: Time Calculation

new topic     » goto parent     » topic index » view thread      » older message » newer message

> Hi, I'm working on an application for my wife's work, and I need to
> calculate how long a worker has worked, given a start time, and an end time.
> Each start/end time is in a sequence like this:
>
> {Hour(1-12), minute(0-59), second(0-59), AM/PM (0/1)}
>
> I need to be able to calculate the number of seconds from the start time to
> the end time, but the AM/PM thing is realy confusing to program with.

Well, take a look at this:
-- This code assumes nobody works more than 23 hours and 59 minutes and 59
seconds

integer shour, smin, ssec, sampm
integer ehour, emin, esec, eampm

-- give those var's some values.
 [ some input routines here ]

-- Get rid of the AMPM thing
if eampm != sampm then
    ehour = ehour + 12
end if

integer totals, totale
totals = ((shour * 60) + smin)*60
totale = ((ehour * 60) + emin)*60

-- Print the difference (the length of the work time) in seconds
? totale-totals

-- You're welcome.










>
> any help would be REALY appreciated!
>
> Thanks,
>     Mark / Liquid-Nitrogen.


>** --------- End Original Message ----------- **

>


Ralf Nieuwenhuijsen

[[ Email ]]
    nieuwen at xs4all.nl
    ralf_n at email.com

[[ I-Seek-You ]]
   UIN: 9389920

[[ The Elevator ]]
    http://www.xs4all.nl/~nieuwen



Download NeoPlanet at http://www.neoplanet.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu