[Commits] [SCM] claws branch, master, updated. 3.14.0-15-gb848844

ticho at claws-mail.org ticho at claws-mail.org
Fri Aug 19 01:46:30 CEST 2016


The branch, master has been updated
       via  b84884479e197092efb1792331dd1c2170ec912b (commit)
      from  c9c7295006daf90a3860305a3a6836c99bfcde11 (commit)

Summary of changes:
 src/plugins/vcalendar/vcal_manager.c |   14 +++++++-------
 src/procheader.c                     |   35 ++++++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 17 deletions(-)


- Log -----------------------------------------------------------------
commit b84884479e197092efb1792331dd1c2170ec912b
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Aug 19 01:44:39 2016 +0200

    More support for pre-Epoch dates for Windows.
    
    get_rfc822_date_from_time_t() (vcalendar)
    procheader_date_parse() (core)

diff --git a/src/plugins/vcalendar/vcal_manager.c b/src/plugins/vcalendar/vcal_manager.c
index 771c731..1432e0f 100644
--- a/src/plugins/vcalendar/vcal_manager.c
+++ b/src/plugins/vcalendar/vcal_manager.c
@@ -519,24 +519,24 @@ gchar *vcal_manager_event_dump(VCalEvent *event, gboolean is_reply, gboolean is_
 
 static void get_rfc822_date_from_time_t(gchar *buf, gint len, time_t t)
 {
+#ifndef G_OS_WIN32
 	struct tm *lt;
 	gchar day[4], mon[4];
 	gint dd, hh, mm, ss, yyyy;
 	gchar buft1[512];
 	struct tm buft2;
 
-#ifndef G_OS_WIN32
 	lt = localtime_r(&t, &buft2);
-#else
-	if (t < 0)
-		t = 1;
-	lt = localtime(&t);
-#endif
-
 	sscanf(asctime_r(lt, buft1), "%3s %3s %d %d:%d:%d %d\n",
 	       day, mon, &dd, &hh, &mm, &ss, &yyyy);
 	g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
 		   day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
+#else
+	GDateTime *dt = g_date_time_new_from_unix_local(t);
+	gchar *buf2 = g_date_time_format(dt, "%a, %e %b %Y %H:%M:%S %Z");
+	strncpy(buf, buf2, len);
+	g_free(buf2);
+#endif
 }
 
 static gchar *write_headers_date(const gchar *uid)
diff --git a/src/procheader.c b/src/procheader.c
index be70c9f..a9bfa5d 100644
--- a/src/procheader.c
+++ b/src/procheader.c
@@ -955,10 +955,8 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
 	gint hh, mm, ss;
 	gchar zone[7];
 	GDateMonth dmonth = G_DATE_BAD_MONTH;
-	struct tm t;
 	gchar *p;
 	time_t timer;
-	time_t tz_offset;
 
 	if (procheader_scan_date_string(src, weekday, &day, month, &year,
 					&hh, &mm, &ss, zone) < 0) {
@@ -967,14 +965,6 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
 		return 0;
 	}
 
-	/* Y2K compliant :) */
-	if (year < 1000) {
-		if (year < 50)
-			year += 2000;
-		else
-			year += 1900;
-	}
-
 	month[3] = '\0';
 	for (p = monthstr; *p != '\0'; p += 3) {
 		if (!g_ascii_strncasecmp(p, month, 3)) {
@@ -983,6 +973,30 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
 		}
 	}
 
+#ifdef G_OS_WIN32
+	GTimeZone *tz;
+	GDateTime *dt;
+
+	tz = g_time_zone_new(zone);
+	dt = g_date_time_new(tz, year, dmonth, day, hh, mm, ss);
+
+	timer = g_date_time_to_unix(dt);
+
+	g_date_time_unref(dt);
+	g_time_zone_unref(tz);
+
+#else
+	struct tm t;
+	time_t tz_offset;
+
+	/* Y2K compliant :) */
+	if (year < 1000) {
+		if (year < 50)
+			year += 2000;
+		else
+			year += 1900;
+	}
+
 	t.tm_sec = ss;
 	t.tm_min = mm;
 	t.tm_hour = hh;
@@ -1000,6 +1014,7 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
 
 	if (dest)
 		procheader_date_get_localtime(dest, len, timer);
+#endif
 
 	return timer;
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list