[dovecot-cvs] dovecot/src/lib-mail rfc822-date.c,1.6,1.7 rfc822-date.h,1.2,1.3

cras at procontrol.fi cras at procontrol.fi
Thu Oct 24 04:15:41 EEST 2002


Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv28234/lib-mail

Modified Files:
	rfc822-date.c rfc822-date.h 
Log Message:
Fixes to timezone handling which were handling quite badly. added
ioloop_timezone which gets updated with ioloop_time. Changed some GMT
references to UTC. Timezone offsets are in minutes now everywhere instead of
seconds. Fixes for unsigned time_t.



Index: rfc822-date.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/rfc822-date.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- rfc822-date.c	11 Oct 2002 22:33:54 -0000	1.6
+++ rfc822-date.c	24 Oct 2002 00:15:39 -0000	1.7
@@ -1,7 +1,8 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "lib.h"
-#include "gmtoff.h"
+#include "utc-offset.h"
+#include "utc-mktime.h"
 #include "rfc822-date.h"
 #include "rfc822-tokenize.h"
 
@@ -196,14 +197,15 @@
 	/* timezone */
 	if (tok == NULL || tok->token != 'A')
 		return FALSE;
-
 	*timezone_offset = parse_timezone(tok->ptr, tok->len);
 
 	tm.tm_isdst = -1;
-	*time = mktime(&tm);
-	if (*time < 0)
+	*time = utc_mktime(&tm);
+	if (*time == (time_t)-1)
 		return FALSE;
 
+	*time -= *timezone_offset;
+
 	return TRUE;
 }
 
@@ -213,14 +215,13 @@
 	int offset, negative;
 
 	tm = localtime(&time);
-	offset = gmtoff(tm, time);
+	offset = utc_offset(tm, time);
 	if (offset >= 0)
 		negative = 0;
 	else {
 		negative = 1;
 		offset = -offset;
 	}
-	offset /= 60;
 
 	return t_strdup_printf("%s, %02d %s %04d %02d:%02d:%02d %c%02d%02d",
 			       weekday_names[tm->tm_wday],

Index: rfc822-date.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/rfc822-date.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rfc822-date.h	11 Oct 2002 22:33:54 -0000	1.2
+++ rfc822-date.h	24 Oct 2002 00:15:39 -0000	1.3
@@ -1,9 +1,8 @@
 #ifndef __RFC822_DATE
 #define __RFC822_DATE
 
-/* Parses RFC822 date/time string. time_t is filled with the date without
-   any timezone changes. timezone_offset is filled with the timezone's
-   difference to UTC in minutes. */
+/* Parses RFC822 date/time string. timezone_offset is filled with the
+   timezone's difference to UTC in minutes. */
 int rfc822_parse_date(const char *str, time_t *time, int *timezone_offset);
 
 /* Create RFC822 date/time string from given time in local timezone. */




More information about the dovecot-cvs mailing list