dovecot-2.0: mbox_from_parse(): When timezone is missing, use th...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 15 03:17:52 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/d9576cda2f33
changeset: 10063:d9576cda2f33
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 14 20:17:44 2009 -0400
description:
mbox_from_parse(): When timezone is missing, use the given time's tz, not the current tz.

diffstat:

2 files changed, 8 insertions(+), 2 deletions(-)
src/lib-mail/mbox-from.c      |    3 ++-
src/lib-mail/test-mbox-from.c |    7 ++++++-

diffs (45 lines):

diff -r 17fefd7fe7b9 -r d9576cda2f33 src/lib-mail/mbox-from.c
--- a/src/lib-mail/mbox-from.c	Wed Oct 14 18:33:03 2009 -0400
+++ b/src/lib-mail/mbox-from.c	Wed Oct 14 20:17:44 2009 -0400
@@ -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 
 	} 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 -r 17fefd7fe7b9 -r d9576cda2f33 src/lib-mail/test-mbox-from.c
--- a/src/lib-mail/test-mbox-from.c	Wed Oct 14 18:33:03 2009 -0400
+++ b/src/lib-mail/test-mbox-from.c	Wed Oct 14 20:17:44 2009 -0400
@@ -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();
 }


More information about the dovecot-cvs mailing list