From: Timo Sirainen Date: Thu, 15 Oct 2009 00:17:44 +0000 (-0400) Subject: mbox_from_parse(): When timezone is missing, use the given time's tz, not the current tz. X-Git-Tag: 2.0.alpha2~100 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bdab9975915a4b6a17088cd2e7a32541b757dec0;p=thirdparty%2Fdovecot%2Fcore.git mbox_from_parse(): When timezone is missing, use the given time's tz, not the current tz. --HG-- branch : HEAD --- diff --git a/src/lib-mail/mbox-from.c b/src/lib-mail/mbox-from.c index a1984fb448..c3468f4931 100644 --- a/src/lib-mail/mbox-from.c +++ b/src/lib-mail/mbox-from.c @@ -4,6 +4,7 @@ #include "ioloop.h" #include "str.h" #include "utc-mktime.h" +#include "utc-offset.h" #include "mbox-from.h" #include @@ -237,7 +238,7 @@ int mbox_from_parse(const unsigned char *msg, size_t size, } else { /* assume local timezone */ *time_r = mktime(&tm); - *tz_offset_r = -timezone/60; + *tz_offset_r = utc_offset(localtime(time_r), *time_r); } *sender_r = i_strdup_until(msg_start, sender_end); diff --git a/src/lib-mail/test-mbox-from.c b/src/lib-mail/test-mbox-from.c index 4bae925bab..c47d88bf33 100644 --- a/src/lib-mail/test-mbox-from.c +++ b/src/lib-mail/test-mbox-from.c @@ -1,6 +1,7 @@ /* Copyright (c) 2009 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "utc-offset.h" #include "mbox-from.h" #include "test-common.h" @@ -79,8 +80,12 @@ static void test_mbox_from_parse(void) static void test_mbox_from_create(void) { + time_t t = 1234567890; + int tz; + test_begin("mbox_from_create()"); - test_assert(strcmp(mbox_from_create("user", 1234567890+timezone), + tz = utc_offset(localtime(&t), t) * -60; + test_assert(strcmp(mbox_from_create("user", t+tz), "From user Fri Feb 13 23:31:30 2009\n") == 0); test_end(); }