comparison src/util.c @ 13426:47e51939c923

[gaim-migrate @ 15801] clean up a little bit committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 07 Mar 2006 04:40:16 +0000
parents 18d5d4018604
children d973e6ba65ac
comparison
equal deleted inserted replaced
13425:95cc25e78ef6 13426:47e51939c923
483 483
484 /************************************************************************** 484 /**************************************************************************
485 * Date/Time Functions 485 * Date/Time Functions
486 **************************************************************************/ 486 **************************************************************************/
487 487
488 #ifdef _WIN32
489 static long win32_get_tz_offset() {
490 TIME_ZONE_INFORMATION tzi;
491 DWORD ret;
492 long off = -1;
493
494 if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
495 {
496 off = -(tzi.Bias * 60);
497 if (ret == TIME_ZONE_ID_DAYLIGHT)
498 off -= tzi.DaylightBias * 60;
499 }
500
501 return off;
502 }
503 #endif
504
488 #ifndef HAVE_STRFTIME_Z_FORMAT 505 #ifndef HAVE_STRFTIME_Z_FORMAT
489 static const char *get_tmoff(const struct tm *tm) 506 static const char *get_tmoff(const struct tm *tm)
490 { 507 {
491 static char buf[6]; 508 static char buf[6];
492 long off; 509 long off;
498 515
499 if (new_tm.tm_isdst < 0) 516 if (new_tm.tm_isdst < 0)
500 g_return_val_if_reached(""); 517 g_return_val_if_reached("");
501 518
502 #ifdef _WIN32 519 #ifdef _WIN32
503 TIME_ZONE_INFORMATION tzi; 520 if ((off = win32_get_tz_offset()) == -1)
504 DWORD ret; 521 return "";
505 if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
506 {
507 off = -(tzi.Bias * 60);
508 if (ret == TIME_ZONE_ID_DAYLIGHT)
509 off -= tzi.DaylightBias * 60;
510 }
511 else
512 return "";
513 #else 522 #else
514 # ifdef HAVE_TM_GMTOFF 523 # ifdef HAVE_TM_GMTOFF
515 off = new_tm.tm_gmtoff; 524 off = new_tm.tm_gmtoff;
516 # else 525 # else
517 # ifdef HAVE_TIMEZONE 526 # ifdef HAVE_TIMEZONE
796 if (tzoff == GAIM_NO_TZ_OFF) 805 if (tzoff == GAIM_NO_TZ_OFF)
797 tzoff = 0; 806 tzoff = 0;
798 #endif 807 #endif
799 808
800 #ifdef _WIN32 809 #ifdef _WIN32
801 TIME_ZONE_INFORMATION tzi; 810 if ((tzoff = win32_get_tz_offset()) == -1)
802 DWORD ret;
803 if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
804 {
805 tzoff -= tzi.Bias * 60;
806 if (ret == TIME_ZONE_ID_DAYLIGHT)
807 {
808 tzoff -= tzi.DaylightBias * 60;
809 }
810 }
811 else
812 tzoff = GAIM_NO_TZ_OFF; 811 tzoff = GAIM_NO_TZ_OFF;
813 #else 812 #else
814 #ifdef HAVE_TM_GMTOFF 813 #ifdef HAVE_TM_GMTOFF
815 tzoff += t->tm_gmtoff; 814 tzoff += t->tm_gmtoff;
816 #else 815 #else