2009-07-29 22:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/utils.c
* contrib/hbtip/tests/tiptime.prg
! Reworked TIP_TIMESTAMP():
! Applied fix from xhb. (with cleanups/optimizations and without
newly introduced bug)
+ Added support for DATETIME type as first parameter.
(at the same time second numeric time parameter is deprecated)
% Simplified code, more optimal API/memory usage.
* Second parameter will always override default time, if passed.
This is a little bit different, but more natural behavior than
before.
+ Replaced meaningless test code with some better one.
; NOTE: We should probably add some core functions to detect TZ offset.
* examples/httpsrv/uhttpdc.c
! Applied above fix/cleanups to HB_UTCOFFSET().
* source/common/hbdate.c
* Minor formatting.
This commit is contained in:
@@ -142,23 +142,21 @@ HB_FUNC( WIN_SYSREFRESH )
|
||||
|
||||
HB_FUNC( HB_UTCOFFSET )
|
||||
{
|
||||
char * szRet = ( char * ) hb_xgrab( 6 );
|
||||
int nLen;
|
||||
char szRet[ 6 ];
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
{
|
||||
TIME_ZONE_INFORMATION tzInfo;
|
||||
DWORD retval = GetTimeZoneInformation( &tzInfo );
|
||||
|
||||
if( GetTimeZoneInformation( &tzInfo ) == TIME_ZONE_ID_INVALID )
|
||||
if( retval == TIME_ZONE_ID_INVALID )
|
||||
tzInfo.Bias = 0;
|
||||
else
|
||||
tzInfo.Bias = -tzInfo.Bias;
|
||||
tzInfo.Bias = -( tzInfo.Bias + ( retval == TIME_ZONE_ID_STANDARD ? tzInfo.StandardBias : tzInfo.DaylightBias ) );
|
||||
|
||||
hb_snprintf( szRet, 6, "%+03d%02d",
|
||||
( int )( tzInfo.Bias / 60 ),
|
||||
( int )( tzInfo.Bias % 60 > 0 ? - tzInfo.Bias % 60 : tzInfo.Bias % 60 ) );
|
||||
|
||||
nLen = strlen( szRet );
|
||||
hb_snprintf( szRet, sizeof( szRet ), "%+03d%02d",
|
||||
( int ) ( tzInfo.Bias / 60 ),
|
||||
( int ) ( tzInfo.Bias % 60 > 0 ? - tzInfo.Bias % 60 : tzInfo.Bias % 60 ) );
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -171,12 +169,9 @@ HB_FUNC( HB_UTCOFFSET )
|
||||
# else
|
||||
tmTime = *localtime( ¤t );
|
||||
# endif
|
||||
nLen = strftime( szRet, 6, "%z", &tmTime );
|
||||
strftime( szRet, sizeof( szRet ), "%z", &tmTime );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( nLen < 6 )
|
||||
szRet = ( char * ) hb_xrealloc( szRet, nLen + 1 );
|
||||
|
||||
hb_retclen_buffer( szRet, nLen );
|
||||
hb_retc( szRet );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user