changeset 20498:6ef43e723595

I think this is the right way to fix timezone. People on Win32 _and_ people on system without HAVE_TM_GMTOFF and with HAVE_TIMEZONE need to test this Everyone else test this too, because I didn't References #2990
author Ka-Hing Cheung <khc@hxbc.us>
date Sun, 09 Sep 2007 00:46:16 +0000
parents 89a82874d64e
children 403ff626b803
files libpurple/protocols/msn/oim.c
diffstat 1 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/oim.c	Sat Sep 08 23:59:25 2007 +0000
+++ b/libpurple/protocols/msn/oim.c	Sun Sep 09 00:46:16 2007 +0000
@@ -448,14 +448,32 @@
 			}
 
 			if (sscanf(tz_ptr, "%02d%02d", &tzhrs, &tzmins) == 2) {
-				t.tm_year -= 1900;
-#if HAVE_TM_GMTOFF
-				t.tm_gmtoff = tzhrs * 60 * 60 + tzmins * 60;
+				time_t tzoff = tzhrs * 60 * 60 + tzmins * 60;
+#ifdef _WIN32
+				long sys_tzoff;
+#endif
+
 				if (!offset_positive)
-					t.tm_gmtoff *= -1;
+					tzoff *= -1;
+
+				t.tm_year -= 1900;
+				t.tm_isdst = 0;
+
+#ifdef _WIN32
+				if ((sys_tzoff = win32_get_tz_offset()) != -1)
+					tzoff += sys_tzoff;
+#else
+#ifdef HAVE_TM_GMTOFF
+				tzoff += t.tm_gmtoff;
+#else
+#	ifdef HAVE_TIMEZONE
+				tzset();    /* making sure */
+				tzoff -= timezone;
+#	endif
 #endif
-				t.tm_isdst = 0;
-				return mktime(&t);
+#endif /* _WIN32 */
+
+				return mktime(&t) + tzoff;
 			}
 		}
 	}