dovecot-2.2-pigeonhole: lib-sieve: date extension: composition o...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Tue Sep 18 13:11:02 EEST 2012


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/fb47824079c7
changeset: 1662:fb47824079c7
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Tue Sep 18 12:10:53 2012 +0200
description:
lib-sieve: date extension: composition of iso8601 dates is moved to Dovecot.

diffstat:

 src/lib-sieve/plugins/date/ext-date-common.c |  53 +++++----------------------
 1 files changed, 11 insertions(+), 42 deletions(-)

diffs (79 lines):

diff -r e31e89e7791b -r fb47824079c7 src/lib-sieve/plugins/date/ext-date-common.c
--- a/src/lib-sieve/plugins/date/ext-date-common.c	Tue Sep 18 11:59:47 2012 +0200
+++ b/src/lib-sieve/plugins/date/ext-date-common.c	Tue Sep 18 12:10:53 2012 +0200
@@ -4,6 +4,7 @@
 #include "lib.h"
 #include "utc-offset.h"
 #include "str.h"
+#include "iso8601-date.h"
 #include "message-date.h"
 
 #include "sieve-common.h"
@@ -345,7 +346,7 @@
 	int day = tm->tm_mday;
 	int c, ya, jd;
 
-	/* Modified from RFC 5260 Appendix A */
+	/* Modified from RFC 5260 Appendix A (refer to Errata) */
 
 	if ( month > 2 )
 		month -= 3;
@@ -389,49 +390,17 @@
 static const char *ext_date_iso8601_part_get
 (struct tm *tm, int zone_offset)
 {
-	const char *time_offset;
+	/* From RFC: `The restricted ISO 8601 format is specified by the date-time
+	 * ABNF production given in [RFC3339], Section 5.6, with the added
+   * restrictions that the letters "T" and "Z" MUST be in upper case, and
+	 * a time zone offset of zero MUST be represented by "Z" and not "+00:00".
+	 */
+	if ( zone_offset == 0 )
+		zone_offset = INT_MAX;
 
-	/*
-	 * RFC 3339: 5.6. Internet Date/Time Format
-	 *
-	 * The following profile of ISO 8601 [ISO8601] dates SHOULD be used in
-	 * new protocols on the Internet.  This is specified using the syntax
-	 * description notation defined in [ABNF].
-	 *
-	 * date-fullyear   = 4DIGIT
-	 * date-month      = 2DIGIT  ; 01-12
-	 * date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on
-	 * 		                     ; month/year
-	 * time-hour       = 2DIGIT  ; 00-23
-	 * time-minute     = 2DIGIT  ; 00-59
-	 * time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second
-	 * 		                     ; rules
-	 * time-secfrac    = "." 1*DIGIT
-	 * time-numoffset  = ("+" / "-") time-hour ":" time-minute
-	 * time-offset     = "Z" / time-numoffset
-	 *
-	 * partial-time    = time-hour ":" time-minute ":" time-second
-	 * 		             [time-secfrac]
-	 * full-date       = date-fullyear "-" date-month "-" date-mday
-	 * full-time       = partial-time time-offset
-	 *
-	 * date-time       = full-date "T" full-time
-	 *
-	 */
+	return iso8601_date_create_tm(tm, zone_offset);
+}
 
-	if ( zone_offset == 0 )
-		time_offset = "Z";
-	else {
-		int offset = zone_offset > 0 ? zone_offset : -zone_offset;
-
-		time_offset = t_strdup_printf
-			("%c%02d:%02d", (zone_offset > 0 ? '+' : '-'), offset / 60, offset % 60);
-	}
-
-	return t_strdup_printf("%04d-%02d-%02dT%02d:%02d:%02d%s",
-		tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min,
-		tm->tm_sec, time_offset);
-}
 
 static const char *ext_date_std11_part_get
 (struct tm *tm, int zone_offset)


More information about the dovecot-cvs mailing list