comparison libpurple/util.c @ 20503:905891855710

3rd time the charm? Fixes #2990, maybe
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 12 Sep 2007 05:36:59 +0000
parents 47a2d00ab060
children 642f08c49042
comparison
equal deleted inserted replaced
20502:b5a2938b4549 20503:905891855710
512 512
513 /************************************************************************** 513 /**************************************************************************
514 * Date/Time Functions 514 * Date/Time Functions
515 **************************************************************************/ 515 **************************************************************************/
516 516
517 #ifdef _WIN32
518 static long win32_get_tz_offset() {
519 TIME_ZONE_INFORMATION tzi;
520 DWORD ret;
521 long off = -1;
522
523 if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
524 {
525 off = -(tzi.Bias * 60);
526 if (ret == TIME_ZONE_ID_DAYLIGHT)
527 off -= tzi.DaylightBias * 60;
528 }
529
530 return off;
531 }
532 #endif
533
534 const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso) 517 const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso)
535 { 518 {
536 static char buf[7]; 519 static char buf[7];
537 long off; 520 long off;
538 gint8 min; 521 gint8 min;
543 526
544 if (new_tm.tm_isdst < 0) 527 if (new_tm.tm_isdst < 0)
545 g_return_val_if_reached(""); 528 g_return_val_if_reached("");
546 529
547 #ifdef _WIN32 530 #ifdef _WIN32
548 if ((off = win32_get_tz_offset()) == -1) 531 if ((off = wpurple_get_tz_offset()) == -1)
549 return ""; 532 return "";
550 #else 533 #else
551 # ifdef HAVE_TM_GMTOFF 534 # ifdef HAVE_TM_GMTOFF
552 off = new_tm.tm_gmtoff; 535 off = new_tm.tm_gmtoff;
553 # else 536 # else
851 if (tzoff == PURPLE_NO_TZ_OFF) 834 if (tzoff == PURPLE_NO_TZ_OFF)
852 tzoff = 0; 835 tzoff = 0;
853 #endif 836 #endif
854 837
855 #ifdef _WIN32 838 #ifdef _WIN32
856 if ((sys_tzoff = win32_get_tz_offset()) == -1) 839 if ((sys_tzoff = wpurple_get_tz_offset()) == -1)
857 tzoff = PURPLE_NO_TZ_OFF; 840 tzoff = PURPLE_NO_TZ_OFF;
858 else 841 else
859 tzoff += sys_tzoff; 842 tzoff += sys_tzoff;
860 #else 843 #else
861 #ifdef HAVE_TM_GMTOFF 844 #ifdef HAVE_TM_GMTOFF