Time Function

Time Function

Postby Jeff Barnes » Sat Apr 07, 2007 1:54 am

Hi Everybody,

Is there a function to convert seconds to a time format like HH:MM:SS ?

Exanple:

nSeconds = 3600

something like SecondsToTime( nSeconds ) would return "01:00:00"


Thanks,
Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Time Function

Postby Enrico Maria Giordano » Sat Apr 07, 2007 7:04 am

Code: Select all  Expand view
FUNCTION MAIN()

    LOCAL nSec := SECONDS()

    ? nSec, SECONDSTOTIME( nSec )

    INKEY( 0 )

    RETURN NIL


STATIC FUNCTION SECONDSTOTIME( nSec )

    LOCAL nHour, nMin

    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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Sat Apr 07, 2007 1:46 pm

Exactly what I needed :D

Thanks Enrico.


Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cmsoft and 47 guests