FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Are there time functions :09:01+5-->:09:06
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Are there time functions :09:01+5-->:09:06
Posted: Wed May 07, 2008 09:45 AM

Hi,
Are there functions like:
09:01 +5 --> 09:06
09:01 -08:01--> 01:01
Thanks !
Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 401
Joined: Thu Oct 06, 2005 10:15 PM
Are there time functions :09:01+5-->:09:06
Posted: Wed May 07, 2008 10:40 AM
Estas Funciones las encontr en el Foro hace muchos años atras
Espero te sirvan...

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

------------------------------------------------------

*/
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Are there time functions :09:01+5--&gt;:09:06
Posted: 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, el teclado y la IA!!"
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Are there time functions :09:01+5--&gt;:09:06
Posted: Thu May 08, 2008 01:24 AM

pablovidal,jose_murugosa,
Thank you!
Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651

Continue the discussion