Jump to content
Fivewin Brasil

Rotina de calc de minutos em clipper (Urgente)


jdmoura

Recommended Posts

Ola pessoal!

Estou precisando urgente de uma rotina que soma os minutos em clipper.

Se alguem tiver e puder me enviar ficarei muito agradecido.

Exe:

00:01:12

00:02:50

00:00:50

01:01:20

--------

01:06:12

Blz

Um clipperAbraço

jdmoura

Jdemourasilva@yahoo.com.br

Londrina - Paraná

Link to comment
Share on other sites

Ola pessoal!

Estou precisando urgente de uma rotina que soma os minutos em clipper.

Se alguem tiver e puder me enviar ficarei muito agradecido.

Exe:

00:01:12

00:02:50

00:00:50

01:01:20

--------

01:06:12

Blz

Um clipperAbraço

jdmoura

Jdemourasilva@yahoo.com.br

Londrina - Paraná

Link to comment
Share on other sites

Elaptime(cTimeInicio,cTimeFinal) mesmo não documentada, esta interna para uso.

Ex:

? elaptime('05:00:30','06:12:10') // Retorno: '01:11:40'

CLIPPER5\SOURCE\SAMPLE\ELAPTIME.PRG

CLIPPER5\SOURCE\SAMPLE\TIME.PRG

Outra funções:


/***

*

* Time.prg

*

* Sample user-defined functions for manipulating time strings

*

* Copyright © 1993, Computer Associates International Inc.

* All rights reserved.

*

* NOTE: Compile with /a /m /n /w

*

*/

/***

*

* SecondsAsDays( ) --> nDays

*

* Convert numeric seconds to days

*

* NOTE: Same as DAYS() in Examplep.prg

*/

FUNCTION SecondsAsDays( nSeconds )

RETURN INT(nSeconds / 86400)

/***

* TimeAsAMPM( ) --> cTime

* Convert a time string to 12-hour format

*

* NOTE: Same as AMPM() in Examplep.prg

*/

FUNCTION TimeAsAMPM( cTime )

IF VAL(cTime) < 12

cTime += " am"

ELSEIF VAL(cTime) = 12

cTime += " pm"

ELSE

cTime := STR(VAL(cTime) - 12, 2) + SUBSTR(cTime, 3) + " pm"

ENDIF

RETURN cTime

/***

* TimeAsSeconds( ) --> nSeconds

* Convert a time string to number of seconds from midnight

*

* NOTE: Same as SECS() in Examplep.prg

*/

FUNCTION TimeAsSeconds( cTime )

RETURN VAL(cTime) * 3600 + VAL(SUBSTR(cTime, 4)) * 60 +;

VAL(SUBSTR(cTime, 7))

/***

* TimeAsString( ) --> cTime

* Convert numeric seconds to a time string

*

* NOTE: Same as TSTRING() in Examplep.prg

*/

FUNCTION TimeAsString( nSeconds )

RETURN StrZero(INT(Mod(nSeconds / 3600, 24)), 2, 0) + ":" +;

StrZero(INT(Mod(nSeconds / 60, 60)), 2, 0) + ":" +;

StrZero(INT(Mod(nSeconds, 60)), 2, 0)

/***

* TimeDiff( , ) --> cDiffTime

* Return the difference between two time strings in the form hh:mm:ss

*

* NOTE: Same as ELAPTIME() in Examplep.prg

*/

FUNCTION TimeDiff( cStartTime, cEndTime )

RETURN TimeAsString(IF(cEndTime < cStartTime, 86400 , 0) +;

TimeAsSeconds(cEndTime) - TimeAsSeconds(cStartTime))

/***

* TimeIsValid( ) --> lValid

* Validate a time string

*

*/

FUNCTION TimeIsValid( cTime )

RETURN VAL(cTime) < 24 .AND. VAL(SUBSTR(cTime, 4)) < 60 .AND.;

VAL(SUBSTR(cTime, 7)) < 60

id=code>id=code>

assinatura3.jpg

Link to comment
Share on other sites

Bom dia jdmoura,

Dia desses, olhando o forum internacional, vi postado o código abaixo, penso que deve servir para que voce possa resolver a sua pendencia:


Código:

/* $DOC$

* $FUNCNAME$

* FT_ELAPSED()

* $CATEGORY$

* Date/Time

* $ONELINER$

* Return elapsed time between two days and/or times

* $SYNTAX$

* FT_ELAPSED([ ], [ ], ;

* , ) -> aTimedata

* $ARGUMENTS$

* is any valid date in any date format. Defaults to DATE().

*

* is any valid date in any date format. Defaults to DATE().

*

* is a valid Time string of the format 'hh:mm:ss' where

* hh is hours in 24-hour format.

*

* is a valid Time string of the format 'hh:mm:ss' where

* hh is hours in 24-hour format.

* $RETURNS$

* A two-dimensional array containing elapsed time data.

* $DESCRIPTION$

* FT_ELAPSED() calculates the elapsed time between two Date/Time events.

*

* It returns an array which contains the following data:

*

* aRetVal[1,1] Integer Days aRetVal[1,2] Total Days (nn.nnnn)

* aRetVal[2,1] Integer Hours aRetVal[2,2] Total Hours (nn.nnnn)

* aRetVal[3,1] Integer Minutes aRetVal[3,2] Total Minutes (nn.nnnn)

* aRetVal[4,1] Integer Seconds aRetVal[4,2] Total Seconds (nn)

* $EXAMPLES$

* FT_ELAPSED(CTOD('11/28/90'), CTOD('11/30/90'), '08:00:00', '12:10:30')

* will return:

*

* aRetVal[1,1] -> 2 (Days) aRetVal[1,2] -> 2.1740 Days

* aRetVal[2,1] -> 4 (Hours) aRetVal[2,2] -> 52.1750 Hours

* aRetVal[3,1] -> 10 (Minutes) aRetVal[3,2] -> 3130.5000 Minutes

* aRetVal[4,1] -> 30 (Seconds) aRetVal[4,2] -> 187830 Seconds

* $END$

*/

FUNCTION FT_ELAPSED(dStart, dEnd, cTimeStart, cTimeEnd)

LOCAL nTotalSec, nCtr, nConstant, nTemp, aRetVal[4,2]

IF ! ( VALTYPE(dStart) $ 'DC' )

dStart := DATE()

ELSEIF VALTYPE(dStart) == 'C'

cTimeStart := dStart

dStart := DATE()

ENDIF

IF ! ( VALTYPE(dEnd) $ 'DC' )

dEnd := DATE()

ELSEIF VALTYPE(dEnd) == 'C'

cTimeEnd := dEnd

dEnd := DATE()

ENDIF

IF( VALTYPE(cTimeStart) != 'C', cTimeStart := '00:00:00', )

IF( VALTYPE(cTimeEnd) != 'C', cTimeEnd := '00:00:00', )

nTotalSec := (dEnd - dStart) * 86400 + ;

VAL(cTimeEnd) * 3600 + ;

VAL(SUBSTR(cTimeEnd,AT(':', cTimeEnd)+1,2)) * 60 + ;

IF(RAT(':', cTimeEnd) == AT(':', cTimeEnd), 0, ;

VAL(SUBSTR(cTimeEnd,RAT(':', cTimeEnd)+1))) - ;

VAL(cTimeStart) * 3600 - ;

VAL(SUBSTR(cTimeStart,AT(':', cTimeStart)+1,2)) * 60 - ;

IF(RAT(':', cTimeStart) == AT(':', cTimeStart), 0, ;

VAL(SUBSTR(cTimeStart,RAT(':', cTimeStart)+1)))

nTemp := nTotalSec

FOR nCtr = 1 to 4

nConstant := IF(nCtr == 1, 86400, IF(nCtr == 2, 3600, IF( nCtr == 3, 60, 1)))

aRetVal[nCtr,1] := INT(nTemp/nConstant)

aRetval[nCtr,2] := nTotalSec / nConstant

nTemp -= aRetVal[nCtr,1] * nConstant

NEXT

RETURN aRetVal

Código:

FUNCTION DEMO()

LOCAL dStart, dEnd, cTimeStart, cTimeEnd, n, aDataTest := {}

dStart := CTOD('11/28/90')

dEnd := CTOD('11/30/90')

cTimeStart := "08:00:00"

cTimeEnd := "12:10:30"

aDataTest := FT_ELAPSED(dStart,dEnd,cTimeStart,cTimeEnd)

FOR n = 1 to 4

? aDataTest[n,1], STR(aDataTest[n,2], 12, 4)

?? " "

?? IF(n == 1, 'Days', IF( n== 2, 'Hours', IF( n == 3, 'Mins.', 'Secs.')))

NEXT

RETURN NIL

Viene en la Nanfor

id=code>id=code>

[]´s

Luiz Augusto

São José dos Pinhais - PR

Harbour47 + Five2.8 + Verce

Vamos Aderir:"Retorne avisando se a dica funcionou"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...