Re: [evolution-patches] [PATCH] Show date in localtime.



On Thu, 2003-08-14 at 12:46, David Woodhouse wrote:
> How about just the day-of-week? I think it's unnecessary but if it makes
> you happier we could do something like...
> 
> 	Date: Tue, 31 Dec 2002 20:24:22 -0600 (Wed 02:24 GMT)

There... not overly cluttered but 100% explicit:
http://www.infradead.org/~dwmw2/evo-show-localtime-day.jpeg

--- ChangeLog.localtime	2003-07-28 17:02:40.000000000 +0100
+++ ChangeLog	2003-08-13 15:20:49.000000000 +0100
@@ -1,3 +1,7 @@
+2003-08-12  David Woodhouse  <dwmw2 infradead org>
+
+	* configure.in: Check for tm_zone in struct tm.
+
 == Version 1.4.4 ==
 
 2003-07-28  Ettore Perazzoli  <ettore ximian com>
--- configure.in.localtime	2003-07-28 17:02:25.000000000 +0100
+++ configure.in	2003-08-13 15:20:49.000000000 +0100
@@ -125,6 +125,7 @@
 dnl ***************
 dnl Timezone checks
 dnl ***************
+AC_CHECK_MEMBERS(struct tm.tm_zone,,,[#include <time.h>])
 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
 	AC_TRY_COMPILE([
 		#include <time.h>
--- mail/ChangeLog.localtime	2003-07-25 16:44:48.000000000 +0100
+++ mail/ChangeLog	2003-08-13 15:20:49.000000000 +0100
@@ -1,3 +1,7 @@
+2003-08-12  David Woodhouse  <dwmw2 infradead org>
+
+	* mail-format.c (write_date): Show date in localtime too.
+
 2003-07-15  Federico Mena Quintero  <federico ximian com>
 
 	* folder-browser.c (message_list_drag_data_received): Handle
--- mail/mail-format.c.localtime	2003-06-25 17:46:29.000000000 +0100
+++ mail/mail-format.c	2003-08-14 14:18:55.000000000 +0100
@@ -48,6 +48,7 @@
 #include <camel/camel-mime-filter-tohtml.h>
 
 #include <e-util/e-trie.h>
+#include <e-util/e-time-utils.h>
 
 #include "mail.h"
 #include "mail-tools.h"
@@ -774,6 +775,10 @@
 	}
 }
 
+static char *tz_days [] = {
+	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
 static void
 write_date (MailDisplayStream *stream, CamelMimeMessage *message, int flags)
 {
@@ -782,8 +787,46 @@
 	datestr = camel_medium_get_header (CAMEL_MEDIUM (message), "Date");
 	
 	if (datestr) {
+		int msg_offset;
+		time_t msg_date;
+		struct tm local;
+		int local_tz;
+
+		msg_date = header_decode_date(datestr, &msg_offset);
+		e_localtime_with_offset(msg_date, &local, &local_tz);
+
 		write_field_row_begin (stream, _("Date"), flags);
-		camel_stream_printf ((CamelStream *) stream, "%s</td> </tr>", datestr);
+		camel_stream_printf ((CamelStream *) stream, "%s", datestr);
+
+		/* Convert message offset to minutes (e.g. -0400 --> -240) */
+		msg_offset = ((msg_offset / 100) * 60) + (msg_offset % 100);
+		/* Turn into offset from localtime, not UTC */
+		msg_offset -= local_tz / 60;
+
+		if (msg_offset) {
+			/* Message timezone different from local. Show both */
+			camel_stream_printf ((CamelStream *) stream, 
+					     "<I> (");
+			
+			msg_offset += (local.tm_hour * 60) + local.tm_min;
+			if (msg_offset > 1439 || msg_offset < 0) {
+				/* Timezone conversion crossed midnight. Show day */
+				camel_stream_printf ((CamelStream *) stream, 
+						     "%s ", 
+						     tz_days[local.tm_wday]);
+			}
+			camel_stream_printf ((CamelStream *) stream, 
+					     "%02d:%02d %s)</I>",
+					     local.tm_hour, local.tm_min,
+#if defined (HAVE_STRUCT_TM_TM_ZONE)
+					     local.tm_zone?:
+#endif
+					     "localtime"
+					     );
+		}
+					     
+		camel_stream_printf ((CamelStream *) stream, "</td> </tr>");
+
 	}
 }
 



-- 
dwmw2




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]