Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Time Elapsed function: Answered my own question.
Message
 
À
16/07/1997 19:39:15
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00040258
Message ID:
00040425
Vues:
30
The code works fine in all cases. This converts the seconds to hours, mintues, and seconds, so the output will look something like: 2h 0m 34s.


>Your code fails if the number of hours or minutes is zero.
>
>Vlad
>
>>Well, I hate sloppy code, so here is the new code using the SECONDS() function. It is considerably smaller:
>>
>>****************************************************************************
>>Procedure R_TimeElapsed &&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>****************************************************************************
>>PARAMETERS pTimeStart,pTimeEnd
>>
>>PRIVATE xElapsed,xSec,xMin,xHour,xReturn
>>
>>if pTimeStart > pTimeEnd
>> xElapsed = (24*60*60)-pTimeStart+pTimeEnd
>>else
>> xElapsed = pTimeEnd - pTimeStart
>>endif
>>
>>if xElapsed >= 3600
>> xHours = Int(xElapsed/3600)
>> xElpased = xElapsed - (3600*xHours)
>>endif
>>if xElapsed >= 60
>> xMin = Int(xTime/60)
>> xElapsed = xElapsed - (60*xMin)
>>endif
>>xSec = xElapsed
>>xReturn = ALLTRIM(STR(xHour))+"h "+ALLTRIM(STR(xMin))+"m ";
>> +ALLTRIM(STR(xSec))+"s"
>>
>>Return xReturn

Michael G. Emmons
memmons@nc.rr.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform