Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Compute Hours, Minutes, Seconds from SECONDS()
Message
De
08/09/1999 03:38:43
 
 
À
08/09/1999 02:01:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00261364
Message ID:
00262286
Vues:
15
>>>Anybody have a technique for measuring the amount of time it takes a function to process?
>>>
>>>I tried the following ... but that give me total seconds and I need the that result converted to hours:minutes:seconds.
>>>
>>>Other Suggestions? Ideas?
>>>
>>>nStart = Seconds()
>>>.
>>>(my code)
>>>.
>>>
>>>nStop = Seconds()
>>>
>>>nRunTime = nStop-nStart
>>>
>>>How to get nRunTime to look like HH:MM:SS??
>>>
>>>Help?
>>>
>>>Please and thanks.
>>
>>
>>? TTOC(DTOT(DATE())+nRunTime,2)
>
>Practically could fit.
>But apart from 12/24 hours setting, it's "set seconds" dependable. If process lasts more than 24 hours, the biggest value you could get would be 23:59:59.

Cetin:

Did you see my code for more than 24 hours?
SET HOURS TO 24
dBase = DATE() && How's that for a variable name! ;)
tEnd = DTOT(dBase) + 87036 && Some elapsed time more than 1 day
?'Days:',TTOD(tEnd)-dBase,TTOC(tEnd,2)

AFAIK, the # of seconds is only limited by how big a single number can be (14 digits?). Well, with 14 digits of 9, that's 1,157,407,407 days and 9+ hours. That should be more than enough time tracking capabilities. :) And by changing, dBase to tBase (DATETIME) then you can just as easily measure elapsed time starting at any given second:

SET HOURS TO 24
tBase = DATETIME()
tEnd = tBase + 1000000 && Some elapsed time more than 1 day
?'Days:',TTOD(tEnd)-TTOD(tBase),TTOC(tEnd,2)


>
* Assuming up to 99:59:59
>? padl(int(nRuntime/3600),2,"0")+":"+;
>  padl(int(nRuntime%3600/60),2,"0")+":"+;
>  padl(nRuntime%60,6,"0")
>
>* Or no milliseconds is needed
>? padl(int(nRuntime/3600),2,"0")+":"+;
>  padl(int(nRuntime%3600/60),2,"0")+":"+;
>  padl(int(nRuntime%60),2,"0")
>OTOH, your TTOC(,2) is a nice way to get time input from user :) Actually I use it combined with a time entry textbox + datetimepicker ActiveX. At textbox gotfocus, textbox sets itself to visible=.f. and sets focus to ActiveX (visible=.t.). That in turn sets textbox value to ttoc(,2) and visible=.t. at lostfocus (activex.visible=.f.). As if it were a Sparse=.t. control in a grid.
>Cetin

I'll have to try your time textbox/Active-X trick. Do you already have a class for it? I'd like to see it if you do. Thanks!
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform