FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Need help "Adding TIME"
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Need help "Adding TIME"
Posted: Sat Jan 06, 2007 09:55 PM
Hi Everybody,

I need a function that will allow me to add seconds to a stored time.

I need to create a loop that will add 4 seconds to each record in the file.

Something like:

cTime := "12:10:58" 
GO TOP
DO WHILE ! EOF()
   MyDbf->TimeField := cTime
   cTime = cTime + 4seconds  //This is where I need help
   SKIP
ENDDO


I need to make sure that it will adjust the minutes or hours as they pass over 60 seconds (or 60 minutes etc...)

Any Ideas?

Thanks
Jeff
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Need help "Adding TIME"
Posted: Sat Jan 06, 2007 10:35 PM
FUNCTION MAIN()

    LOCAL cTime := TIME()

    ? cTime, ADDSECONDS( cTime, 4 )

    RETURN NIL


STATIC FUNCTION ADDSECONDS( cTime, nSec )

    LOCAL nHour, nMin

    nSec = ( VAL( LEFT( cTime, 2 ) ) * 3600 + VAL( SUBSTR( cTime, 4, 2 ) ) * 60 + VAL( RIGHT( cTime, 2 ) ) + nSec ) % 86400

    nHour = INT( nSec / 3600 )

    nSec -= nHour * 3600

    nMin = INT( nSec / 60 )

    nSec -= nMin * 60

    RETURN STRZERO( nHour, 2 ) + ":" + STRZERO( nMin, 2 ) + ":" + STRZERO( nSec, 2 )


EMG
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Need help "Adding TIME"
Posted: Sun Jan 07, 2007 12:20 AM

My hat is off to you sir :D

Once again your solution works perfectly.

Thanks Enrico,

Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)

Continue the discussion