2009-07-29 23:46 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/hbdate.h
* source/common/hbdate.c
* contrib/hbtip/utils.c
* examples/httpsrv/uhttpdc.c
+ Added hb_timeUTCOffset( void ) -> long (in seconds)
% Using hb_timeUTCOffset() in TIP_TIMESTAMP() and HB_UTCOFFSET().
These functions can now be implemented on .prg level if we
add a .prg level wrapper for hb_timeUTCOffer(), but I have no
good idea which format to use to return this value, so maybe
simple signed number of seconds.
This commit is contained in:
@@ -143,35 +143,11 @@ HB_FUNC( WIN_SYSREFRESH )
|
||||
HB_FUNC( HB_UTCOFFSET )
|
||||
{
|
||||
char szRet[ 6 ];
|
||||
long offset = hb_timeUTCOffset();
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
{
|
||||
TIME_ZONE_INFORMATION tzInfo;
|
||||
DWORD retval = GetTimeZoneInformation( &tzInfo );
|
||||
|
||||
if( retval == TIME_ZONE_ID_INVALID )
|
||||
tzInfo.Bias = 0;
|
||||
else
|
||||
tzInfo.Bias = -( tzInfo.Bias + ( retval == TIME_ZONE_ID_STANDARD ? tzInfo.StandardBias : tzInfo.DaylightBias ) );
|
||||
|
||||
hb_snprintf( szRet, sizeof( szRet ), "%+03d%02d",
|
||||
( int ) ( tzInfo.Bias / 60 ),
|
||||
( int ) ( tzInfo.Bias % 60 > 0 ? - tzInfo.Bias % 60 : tzInfo.Bias % 60 ) );
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct tm tmTime;
|
||||
time_t current;
|
||||
|
||||
time( ¤t );
|
||||
# if defined( HB_HAS_LOCALTIME_R )
|
||||
localtime_r( ¤t, &tmTime );
|
||||
# else
|
||||
tmTime = *localtime( ¤t );
|
||||
# endif
|
||||
strftime( szRet, sizeof( szRet ), "%z", &tmTime );
|
||||
}
|
||||
#endif
|
||||
hb_snprintf( szRet, sizeof( szRet ), "%+03d%02d",
|
||||
( int ) ( offset / 3600 ),
|
||||
( int ) ( ( offset % 3600 ) / 60 ) );
|
||||
|
||||
hb_retc( szRet );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user