qulogic/pidgin

Fix purple_str_to_time() again.
release-2.x.y
2014-01-21, Richard Laager
e5c1b7f9486d
Fix purple_str_to_time() again.

Mark pointed out that the 2010-08-27.134202-0700PDT test was failing.
I've expanded that test to check the various returned parameters
(other than the struct tm).

Before 6a74f42c8c04: the returned time_t is (on my system) off by
an hour. (It returned 1282938122 instead of 1282941722.) This was
reported in #13131.

6a74f42c8c04 fixed that, but switched the sign on the returned tz_off.
This was reported as a bug in #15675.

I fixed that in f93f8b0f36c3, but that broke the tests. Mark reported
it was returning 1282891322.

This commit fixes that, while not breaking the tz_off.
--- a/libpurple/tests/test_util.c Tue Jan 21 19:13:55 2014 +0100
+++ b/libpurple/tests/test_util.c Tue Jan 21 18:28:54 2014 -0600
@@ -156,10 +156,19 @@
START_TEST(test_util_str_to_time)
{
+ struct tm tm;
+ long tz_off;
+ const char *rest;
+ time_t timestamp;
+
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));
fail_unless(1282941722 == purple_str_to_time("2010-08-27.204202", TRUE, NULL, NULL, NULL));
- fail_unless(1282941722 == purple_str_to_time("2010-08-27.134202-0700PDT", FALSE, NULL, NULL, NULL));
+
+ timestamp = purple_str_to_time("2010-08-27.134202-0700PDT", FALSE, &tm, &tz_off, &rest);
+ fail_unless(1282941722 == timestamp);
+ fail_unless((-7 * 60 * 60) == tz_off);
+ assert_string_equal("PDT", rest);
}
END_TEST
--- a/libpurple/util.c Tue Jan 21 19:13:55 2014 +0100
+++ b/libpurple/util.c Tue Jan 21 18:28:54 2014 -0600
@@ -860,7 +860,7 @@
*tm = t;
if (tzoff != PURPLE_NO_TZ_OFF)
- retval += tzoff;
+ retval -= tzoff;
if (tz_off != NULL)
*tz_off = tzoff;