Mercurial > pidgin.yaz
changeset 21612:18fb032a602a
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 ;-)
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 22 Nov 2007 16:37:08 +0000 |
parents | 87387eac4348 |
children | 31101e7d275f |
files | libpurple/tests/test_util.c libpurple/util.c |
diffstat | 2 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/tests/test_util.c Thu Nov 22 16:32:56 2007 +0000 +++ b/libpurple/tests/test_util.c Thu Nov 22 16:37:08 2007 +0000 @@ -76,7 +76,7 @@ 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
--- a/libpurple/util.c Thu Nov 22 16:32:56 2007 +0000 +++ b/libpurple/util.c Thu Nov 22 16:37:08 2007 +0000 @@ -837,7 +837,19 @@ } 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')