comparison libpurple/util.c @ 20521:3cdf78c6c850

propagate from branch 'im.pidgin.pidgin' (head 5a3c2bb6d5725a73e614aa69d0e5beb04aba2d19) to branch 'im.pidgin.cpw.khc.msnp14' (head 62acf636b8dff8ae149e05aa9409e13951218ab5)
author Richard Laager <rlaager@wiktel.com>
date Sun, 16 Sep 2007 18:11:54 +0000
parents bd60afa72fce
children a9022965162b
comparison
equal deleted inserted replaced
20090:e638dec3d76b 20521:3cdf78c6c850
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