im.pidgin.pidgin: 4ad840403f424f99fb7980fcbba81877eaf883d3

nosnilmot at pidgin.im nosnilmot at pidgin.im
Thu Nov 22 11:50:42 EST 2007


-----------------------------------------------------------------
Revision: 4ad840403f424f99fb7980fcbba81877eaf883d3
Ancestor: d8eeeb11a340ddd5f02497312625bf290f71a4b7
Author: nosnilmot at pidgin.im
Date: 2007-11-22T16:37:08
Branch: im.pidgin.pidgin

Modified files:
        libpurple/tests/test_util.c libpurple/util.c

ChangeLog: 

Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Also fix the test value that 'make check' was using. that didn't help ;-)

-------------- next part --------------
============================================================
--- libpurple/tests/test_util.c	ea544aa2e1e78081673ca49960c37b54ff558b08
+++ libpurple/tests/test_util.c	ba2e94b404cad9ad2f4d913aef40e9fa0227e198
@@ -76,7 +76,7 @@ START_TEST(test_util_str_to_time)
 
 START_TEST(test_util_str_to_time)
 {
-	fail_unless(377185800 == purple_str_to_time("19811214T12:50:00", TRUE, NULL, NULL, NULL));
+	fail_unless(377182200 == purple_str_to_time("19811214T12:50:00", TRUE, NULL, NULL, NULL));
 	fail_unless(1175919261 == purple_str_to_time("20070407T04:14:21", TRUE, NULL, NULL, NULL));
 }
 END_TEST
============================================================
--- libpurple/util.c	c9b883b72cd5b442be0b31e5ba9268366f206843
+++ libpurple/util.c	8a0714f7a8261c6f88d9612cdf595c0881183b56
@@ -837,7 +837,19 @@ purple_str_to_time(const char *timestamp
 			}
 			else if (utc)
 			{
-				t->tm_isdst = -1;
+				struct tm *tmptm;
+				time_t tmp;
+				tmp = mktime(t);
+				/* we care about whether it *was* dst, and the offset, here on this
+				 * date, not whether we are currently observing dst locally *now*.
+				 * This isn't perfect, because we would need to know in advance the
+				 * offset we are trying to work out in advance to be sure this
+				 * works for times around dst transitions but it'll have to do. */
+				tmptm = localtime(&tmp);
+				t->tm_isdst = tmptm->tm_isdst;
+#ifdef HAVE_TM_GMTOFF
+				t->tm_gmtoff = tmptm->tm_gmtoff;
+#endif
 			}
 
 			if (rest != NULL && *c != '\0')


More information about the Commits mailing list