Page 1 of 1
Are there time functions :09:01+5-->:09:06
Posted: Wed May 07, 2008 9:45 am
by ShumingWang
Hi,
Are there functions like:
09:01 +5 --> 09:06
09:01 -08:01--> 01:01
Thanks !
Shuming Wang
Posted: Wed May 07, 2008 10:40 am
by pablovidal
Estas Funciones las encontr en el Foro hace muchos aƱos atras
Espero te sirvan...
Code: Select all
*+--------------------------------------------------------------------
*+
*+ Function TimeAsSeconds()
*+
*+--------------------------------------------------------------------
*+
FUNCTION TimeAsSeconds( cTime )
RETURN VAL( cTime ) * 3600 + VAL( SUBSTR( cTime, 4 ) ) * 60 + VAL( SUBSTR( cTime, 7 ) )
*+--------------------------------------------------------------------
*+
*+ Function TimeAsSeconds()
*+
*+--------------------------------------------------------------------
*+
FUNCTION TimeAsMinute( cTime )
LOCAL nSEC := VAL( cTime ) * 3600 + VAL( SUBSTR( cTime, 4 ) ) * 60 //+ VAL( SUBSTR( cTime, 7 ) )
RETURN( nSEC / 60 )
*+--------------------------------------------------------------------
*+
*+ Function TimeAsString()
*+
*+--------------------------------------------------------------------
*+
FUNCTION TimeAsChar( 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 )
*+--------------------------------------------------------------------
*+
*+ Function TimeAsString()
*+
*+--------------------------------------------------------------------
*+
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 )
*+--------------------------------------------------------------------
*+
*+ Function TimeDiff()
*+
*+--------------------------------------------------------------------
*+
FUNCTION TimeDiff( cStartTime, cEndTime )
Default cEndTime := Time()
RETURN TimeAsString( IF( cEndTime < cStartTime, 86400, 0 ) + ;
TimeAsSeconds( cEndTime ) - TimeAsSeconds( cStartTime ) )
*+--------------------------------------------------------------------
*+
*+ Function TimeIsValid() 20:20:00
*+
*+--------------------------------------------------------------------
*+
FUNCTION TimeIsValid( cTime )
RETURN VAL( cTime ) < 24 .AND. VAL( SUBSTR( cTime, 4 ) ) < 60 .AND. VAL( SUBSTR( cTime, 7 ) ) < 60
Re: Are there time functions :09:01+5-->:09:06
Posted: Wed May 07, 2008 11:16 am
by jose_murugosa
ShumingWang wrote:Hi,
Are there functions like:
09:01 +5 --> 09:06
09:01 -08:01--> 01:01
Thanks !
Shuming Wang
This ar native functions of xharbour:
Secs()
Calculates the number of seconds from a time string.
Syntax
Secs( <cTime>|<dDateTime> ) --> nSeconds
TString()
Converts numeric seconds into a time formatted character string.
Syntax
TString( <nSeconds> ) --> cTimeString
I hope It may help.
Posted: Thu May 08, 2008 1:24 am
by ShumingWang
pablovidal,jose_murugosa,
Thank you!
Shuming Wang