comparison libpurple/util.c @ 20541:a9022965162b

propagate from branch 'im.pidgin.cpw.khc.msnp14' (head 60c1ae856c10cfcb75590f268816616e8a005aa1) to branch 'im.pidgin.pidgin' (head 50f213de2725c1ebf3b9c7d9082ff92538c984ed)
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 19 Sep 2007 06:22:25 +0000
parents 2ab6b55ffa3d bd60afa72fce
children 45b524709475
comparison
equal deleted inserted replaced
20177:c9a5a2edda7c 20541:a9022965162b
513 513
514 /************************************************************************** 514 /**************************************************************************
515 * Date/Time Functions 515 * Date/Time Functions
516 **************************************************************************/ 516 **************************************************************************/
517 517
518 #ifdef _WIN32
519 static long win32_get_tz_offset() {
520 TIME_ZONE_INFORMATION tzi;
521 DWORD ret;
522 long off = -1;
523
524 if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
525 {
526 off = -(tzi.Bias * 60);
527 if (ret == TIME_ZONE_ID_DAYLIGHT)
528 off -= tzi.DaylightBias * 60;
529 }
530
531 return off;
532 }
533 #endif
534
535 const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso) 518 const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso)
536 { 519 {
537 static char buf[7]; 520 static char buf[7];
538 long off; 521 long off;
539 gint8 min; 522 gint8 min;
544 527
545 if (new_tm.tm_isdst < 0) 528 if (new_tm.tm_isdst < 0)
546 g_return_val_if_reached(""); 529 g_return_val_if_reached("");
547 530
548 #ifdef _WIN32 531 #ifdef _WIN32
549 if ((off = win32_get_tz_offset()) == -1) 532 if ((off = wpurple_get_tz_offset()) == -1)
550 return ""; 533 return "";
551 #else 534 #else
552 # ifdef HAVE_TM_GMTOFF 535 # ifdef HAVE_TM_GMTOFF
553 off = new_tm.tm_gmtoff; 536 off = new_tm.tm_gmtoff;
554 # else 537 # else
852 if (tzoff == PURPLE_NO_TZ_OFF) 835 if (tzoff == PURPLE_NO_TZ_OFF)
853 tzoff = 0; 836 tzoff = 0;
854 #endif 837 #endif
855 838
856 #ifdef _WIN32 839 #ifdef _WIN32
857 if ((sys_tzoff = win32_get_tz_offset()) == -1) 840 if ((sys_tzoff = wpurple_get_tz_offset()) == -1)
858 tzoff = PURPLE_NO_TZ_OFF; 841 tzoff = PURPLE_NO_TZ_OFF;
859 else 842 else
860 tzoff += sys_tzoff; 843 tzoff += sys_tzoff;
861 #else 844 #else
862 #ifdef HAVE_TM_GMTOFF 845 #ifdef HAVE_TM_GMTOFF