From 1237de4177f0530a9093b197584fd12dba43664e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 30 Jul 2009 06:50:56 +0000 Subject: [PATCH] 2009-07-30 08:48 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/common/hbdate.c + Enhancement to hb_timeUTCOffset(). (using thread safe version of gmtime() where available, and precisely checking tm_isdst). Thanks to Przemek. --- harbour/ChangeLog | 6 ++++++ harbour/source/common/hbdate.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b802dfce7b..fa6f5ded71 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-30 08:48 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * source/common/hbdate.c + + Enhancement to hb_timeUTCOffset(). (using thread safe + version of gmtime() where available, and precisely checking + tm_isdst). Thanks to Przemek. + 2009-07-30 06:59 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/common/hbdate.c ! Refixed for HB_HAS_LOCALTIME_R. diff --git a/harbour/source/common/hbdate.c b/harbour/source/common/hbdate.c index 7de8b03d43..b3e65bdba8 100644 --- a/harbour/source/common/hbdate.c +++ b/harbour/source/common/hbdate.c @@ -916,16 +916,16 @@ long hb_timeUTCOffset( void ) /* in seconds */ time_t current, utc, local; time( ¤t ); - utc = mktime( gmtime( ¤t ) ); #if defined( HB_HAS_LOCALTIME_R ) - localtime_r( ¤t, &timeinfo ); + utc = mktime( gmtime_r( ¤t, &timeinfo ) ); + local = mktime( localtime_r( ¤t, &timeinfo ) ); #else + utc = mktime( gmtime( ¤t ) ); timeinfo = *localtime( ¤t ); -#endif local = mktime( &timeinfo ); - - return difftime( local, utc ) + ( timeinfo.tm_isdst ? 3600 : 0 ); +#endif + return difftime( local, utc ) + ( timeinfo.tm_isdst > 0 ? 3600 : 0 ); } #endif }