]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox_from_parse(): When timezone is missing, use the given time's tz, not the current tz.
authorTimo Sirainen <tss@iki.fi>
Thu, 15 Oct 2009 00:17:44 +0000 (20:17 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 15 Oct 2009 00:17:44 +0000 (20:17 -0400)
--HG--
branch : HEAD

src/lib-mail/mbox-from.c
src/lib-mail/test-mbox-from.c

index a1984fb44825c36301a6b9d5835f6a0eab7a93b8..c3468f493115a49855aae0a5ecafbf8ce084e914 100644 (file)
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "str.h"
 #include "utc-mktime.h"
+#include "utc-offset.h"
 #include "mbox-from.h"
 
 #include <time.h>
@@ -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);
index 4bae925bab0fd5d09160dee2e35c95d3a3ac25e6..c47d88bf3306865cecc411cc3a9f0331cad8fe24 100644 (file)
@@ -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();
 }