Are there time functions :09:01+5-->:09:06

Are there time functions :09:01+5-->:09:06

Postby ShumingWang » Wed May 07, 2008 9:45 am

Hi,
Are there functions like:
09:01 +5 --> 09:06
09:01 -08:01--> 01:01
Thanks !
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby pablovidal » Wed May 07, 2008 10:40 am

Estas Funciones las encontr en el Foro hace muchos años atras
Espero te sirvan...

Code: Select all  Expand view

*+--------------------------------------------------------------------
*+
*+    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


Saludos,

Pablo Alberto Vidal
/*
------------------------------------------------------
Harbour 3.2.0, Fivewin 17.02, BCC7
------------------------------------------------------
*/
User avatar
pablovidal
 
Posts: 401
Joined: Thu Oct 06, 2005 10:15 pm
Location: Republica Dominicana

Re: Are there time functions :09:01+5-->:09:06

Postby jose_murugosa » Wed May 07, 2008 11:16 am

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.
Saludos/Regards,
José Murugosa
"Los errores en programación, siempre están entre la silla y el teclado y la IA!!"
User avatar
jose_murugosa
 
Posts: 1180
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby ShumingWang » Thu May 08, 2008 1:24 am

pablovidal,jose_murugosa,
Thank you!
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests