diff options
author | Gary Kramlich <grim@reaperworld.com> | 2022-01-24 20:22:15 -0600 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2022-01-24 20:22:15 -0600 |
commit | 15bc2c3d2fdd3f0567ea8e59beb21aaab68bbe6c (patch) | |
tree | a8a1b17ec1127ac82581f7ec96e9c946a2a9c053 | |
parent | 67561eba079d14da38af27949af21b2e3ca2c106 (diff) | |
download | pidgin-15bc2c3d2fdd3f0567ea8e59beb21aaab68bbe6c.tar.gz |
Fix gentoo-819774.
I'm not sure if we needed the code that I duplicated but I really don't want to
rock the board anymore with this function. This causes all unit tests to pass
and everthing seems okay now?
Testing Done:
Ran the unit tests with TZ values of empty, `Asia/Kathmandu` and `Pacific/Auckland`.
Reviewed at https://reviews.imfreedom.org/r/1238/
-rw-r--r-- | libpurple/tests/test_util.c | 9 | ||||
-rw-r--r-- | libpurple/util.c | 11 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libpurple/tests/test_util.c b/libpurple/tests/test_util.c index 044a360997..7639d72afa 100644 --- a/libpurple/tests/test_util.c +++ b/libpurple/tests/test_util.c @@ -172,7 +172,7 @@ START_TEST(test_util_str_to_time) fail_unless(1282941722 == purple_str_to_time("2010-08-27.204202", TRUE, NULL, NULL, NULL)); fail_unless(1175919261 == purple_str_to_time("20070407T04:14:21.3234", TRUE, NULL, NULL, NULL)); fail_unless(1175919261 == purple_str_to_time("20070407T04:14:21Z", TRUE, NULL, NULL, NULL)); - fail_unless(1631512800 == purple_str_to_time("09-13-2021", TRUE, NULL, NULL, NULL)); + fail_unless(1631491200 == purple_str_to_time("09-13-2021", TRUE, NULL, NULL, NULL)); /* For testing local time we use Asia/Kathmandu because it's +05:45 and * doesn't have DST which means the test should always pass regardless of @@ -195,9 +195,14 @@ START_TEST(test_util_str_to_time) * localtime. */ timestamp = purple_str_to_time("09/13/202115:34:34", TRUE, NULL, NULL, &rest); - fail_unless(1631470500 == timestamp); + fail_unless(1631491200 == timestamp); assert_string_equal("15:34:34", rest); + 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); + /* finally revert the TZ environment variable */ if(oldtz != NULL) { g_setenv("TZ", oldtz, TRUE); diff --git a/libpurple/util.c b/libpurple/util.c index 9bf463a425..fa650c2de7 100644 --- a/libpurple/util.c +++ b/libpurple/util.c @@ -887,6 +887,17 @@ purple_str_to_time(const char *timestamp, gboolean utc, t.tm_isdst = -1; /* -1 means dst info is not available */ } } + } else { + /* If we have a time, figure out if we need to adjust our tz offset. */ + if(!mktime_with_utc) { + if(utc) { + mktime_with_utc = TRUE; + tzoff = 0; + } else { + /* Local Time */ + t.tm_isdst = -1; /* -1 means dst info is not available */ + } + } } g_free(hours); |