# HG changeset patch # User Daniel Atallah # Date 1141706416 0 # Node ID 47e51939c923b360f3749609af813a4f0e4a7966 # Parent 95cc25e78ef6eb6957596f8d08b52fd8c0b46f70 [gaim-migrate @ 15801] clean up a little bit committer: Tailor Script diff -r 95cc25e78ef6 -r 47e51939c923 src/util.c --- a/src/util.c Tue Mar 07 04:26:44 2006 +0000 +++ b/src/util.c Tue Mar 07 04:40:16 2006 +0000 @@ -485,6 +485,23 @@ * Date/Time Functions **************************************************************************/ +#ifdef _WIN32 +static long win32_get_tz_offset() { + TIME_ZONE_INFORMATION tzi; + DWORD ret; + long off = -1; + + if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID) + { + off = -(tzi.Bias * 60); + if (ret == TIME_ZONE_ID_DAYLIGHT) + off -= tzi.DaylightBias * 60; + } + + return off; +} +#endif + #ifndef HAVE_STRFTIME_Z_FORMAT static const char *get_tmoff(const struct tm *tm) { @@ -500,16 +517,8 @@ g_return_val_if_reached(""); #ifdef _WIN32 - TIME_ZONE_INFORMATION tzi; - DWORD ret; - if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID) - { - off = -(tzi.Bias * 60); - if (ret == TIME_ZONE_ID_DAYLIGHT) - off -= tzi.DaylightBias * 60; - } - else - return ""; + if ((off = win32_get_tz_offset()) == -1) + return ""; #else # ifdef HAVE_TM_GMTOFF off = new_tm.tm_gmtoff; @@ -798,17 +807,7 @@ #endif #ifdef _WIN32 - TIME_ZONE_INFORMATION tzi; - DWORD ret; - if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID) - { - tzoff -= tzi.Bias * 60; - if (ret == TIME_ZONE_ID_DAYLIGHT) - { - tzoff -= tzi.DaylightBias * 60; - } - } - else + if ((tzoff = win32_get_tz_offset()) == -1) tzoff = GAIM_NO_TZ_OFF; #else #ifdef HAVE_TM_GMTOFF