From 1e5b62defaae5d47cef2dbd23ae8ed7bd6bd3283 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 21 Apr 2009 09:49:02 +0000 Subject: [PATCH] 2009-04-21 11:56 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/hbdate.c ! fixed decoding fractional part of seconds in timestamp expressions when less the 3 digits were used. * harbour/source/rtl/dateshb.c + added optional logical parameter to hb_TSToStr() function to enabled packed/stripped form * harbour/source/rtl/valtoexp.prg % use hb_TSToStr() with new pack parameter in hb_ValToExp() and hb_CStr() --- harbour/ChangeLog | 12 ++++++++++++ harbour/source/common/hbdate.c | 6 +++--- harbour/source/rtl/dateshb.c | 34 ++++++++++++++++++++++++++++++++- harbour/source/rtl/valtoexp.prg | 4 ++-- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 350d9bc615..ef804923fb 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,18 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-04-21 11:56 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/common/hbdate.c + ! fixed decoding fractional part of seconds in timestamp expressions + when less the 3 digits were used. + + * harbour/source/rtl/dateshb.c + + added optional logical parameter to hb_TSToStr() function to enabled + packed/stripped form + + * harbour/source/rtl/valtoexp.prg + % use hb_TSToStr() with new pack parameter in hb_ValToExp() and hb_CStr() + 2009-04-21 04:19 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg ! Fixed minor but fatal oversight in prev commit. diff --git a/harbour/source/common/hbdate.c b/harbour/source/common/hbdate.c index 5753e18d02..e99ace30ce 100644 --- a/harbour/source/common/hbdate.c +++ b/harbour/source/common/hbdate.c @@ -510,12 +510,12 @@ BOOL hb_timeStrGet( const char * szTime, { ++iBlocks; ++szTime; - iMSec = ( *szTime++ - '0' ); + iMSec = ( *szTime++ - '0' ) * 100; if( HB_ISDIGIT( *szTime ) ) { - iMSec = iMSec * 10 + ( *szTime++ - '0' ); + iMSec += ( *szTime++ - '0' ) * 10; if( HB_ISDIGIT( *szTime ) ) - iMSec = iMSec * 10 + ( *szTime++ - '0' ); + iMSec += ( *szTime++ - '0' ); } if( HB_ISDIGIT( *szTime ) ) ++szTime; diff --git a/harbour/source/rtl/dateshb.c b/harbour/source/rtl/dateshb.c index f712f0ecdc..75081b74e1 100644 --- a/harbour/source/rtl/dateshb.c +++ b/harbour/source/rtl/dateshb.c @@ -375,7 +375,39 @@ HB_FUNC( HB_TSTOSTR ) { char szBuffer[ 24 ]; - hb_retc( hb_timeStampStr( szBuffer, lDate, lTime ) ); + hb_timeStampStr( szBuffer, lDate, lTime ); + if( ISLOG( 2 ) && hb_parl( 2 ) ) + { + if( lTime == 0 ) + { + if( lDate == 0 ) + hb_retc( "00:00" ); + else + { + szBuffer[ 10 ] = '\0'; + hb_retc( szBuffer ); + } + } + else + { + int i = 23; + while( szBuffer[ i - 1 ] == '0' ) + --i; + if( szBuffer[ i - 1 ] == '.' ) + { + --i; + if( szBuffer[ i - 1 ] == '0' && szBuffer[ i - 2 ] == '0' ) + i -= 3; + } + szBuffer[ i ] = '\0'; + if( lDate == 0 ) + hb_retc( szBuffer + 11 ); + else + hb_retc( szBuffer ); + } + } + else + hb_retc( szBuffer ); } else hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); diff --git a/harbour/source/rtl/valtoexp.prg b/harbour/source/rtl/valtoexp.prg index 46e19b5b4b..7fc5058b11 100644 --- a/harbour/source/rtl/valtoexp.prg +++ b/harbour/source/rtl/valtoexp.prg @@ -66,7 +66,7 @@ FUNCTION hb_VALTOEXP( xVal ) cVal := iif( Empty( xVal ), "0d00000000", "0d" + DToS( xVal ) ) EXIT CASE "T" - cVal := iif( Empty( xVal ), 't"00:00"', 't"' + hb_TSToStr( xVal ) + '"' ) + cVal := 't"' + hb_TSToStr( xVal, .T. ) + '"' EXIT CASE "L" cVal := iif( xVal, ".T.", ".F." ) @@ -128,7 +128,7 @@ FUNCTION hb_CStr( xVal ) CASE "D" RETURN iif( Empty( xVal ), "0d00000000", "0d" + DToS( xVal ) ) CASE "T" - RETURN iif( Empty( xVal ), 't"00:00"', 't"' + hb_TSToStr( xVal ) + '"' ) + cVal := 't"' + hb_TSToStr( xVal, .T. ) + '"' CASE "L" RETURN iif( xVal, ".T.", ".F." ) CASE "S"