[Xfce4-commits] <postler:master> Use Today/ Yesterday in dates also in the message view

Christian Dywan noreply at xfce.org
Sun Nov 7 03:24:01 CET 2010


Updating branch refs/heads/master
         to 5fe8cbc2d9bd6194889fa1c12b1f3321e564fc4a (commit)
       from bc61cd789879547ed61743a7ffae45a0df0f74ab (commit)

commit 5fe8cbc2d9bd6194889fa1c12b1f3321e564fc4a
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Nov 7 03:23:41 2010 +0100

    Use Today/ Yesterday in dates also in the message view

 postler/postler-messages.vala |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index dd536d0..5d6e6ef 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -131,13 +131,14 @@ public class Postler.Messages : Gtk.TreeView {
                          Columns.FROM, out from);
 
         subject = escape_text (parse_encoded (subject, out charset));
+        var now = GLib.Date ();
+        now.set_time_val (GLib.TimeVal ());
+        string date = Postler.Messages.format_timestamp (timestamp, now);
         from = escape_text (parse_address (parse_encoded (from, out charset))[0]);
         renderer.ellipsize = Pango.EllipsizeMode.END;
         renderer.markup = ("<span weight=\"%d\">%s</span>\n" +
                            "<small><tt>%s      </tt></small> %s").printf (
-                           weight, subject,
-                           GLib.Time.local (timestamp).format ("%x %X"),
-                           from);
+                           weight, subject, date, from);
     }
 
     void render_from (Gtk.TreeViewColumn column, Gtk.CellRenderer cell,
@@ -163,7 +164,9 @@ public class Postler.Messages : Gtk.TreeView {
         else {
             time_t timestamp;
             model.get (iter, Columns.TIMESTAMP, out timestamp);
-            renderer.text = GLib.Time.local (timestamp).format ("%x %X");
+            var now = GLib.Date ();
+            now.set_time_val (GLib.TimeVal ());
+            renderer.text = Postler.Messages.format_timestamp (timestamp, now);
         }
     }
 
@@ -396,20 +399,24 @@ public class Postler.Messages : Gtk.TreeView {
         content.clear ();
     }
 
-    internal static string format_date (string date, GLib.Date now,
-        out time_t timestamp) {
-        var parsed = new Soup.Date.from_string (date);
-        timestamp = parsed != null ? (time_t)parsed.to_time_t () : 0;
+    internal static string format_timestamp (time_t timestamp, GLib.Date now) {
         var the_time = GLib.Date ();
         the_time.set_time_t (timestamp);
         int days = now.days_between (the_time);
         if (days == 0)
             return _("Today") + GLib.Time.local (timestamp).format (" %X");
         if (days == 1)
-            return _("Yesterday") + GLib.Time.local (timestamp).format ("%X");
+            return _("Yesterday") + GLib.Time.local (timestamp).format (" %X");
         return GLib.Time.local (timestamp).format ("%x %X");
     }
 
+    internal static string format_date (string date, GLib.Date now,
+        out time_t timestamp) {
+        var parsed = new Soup.Date.from_string (date);
+        timestamp = parsed != null ? (time_t)parsed.to_time_t () : 0;
+        return format_timestamp (timestamp, now);
+    }
+
     static string flags_from_filename (string filename, out string bare_filename) {
         string[]? parts = filename.split (":");
         if (parts == null || parts[0] == null || parts[1] == null) {



More information about the Xfce4-commits mailing list