* modest_text_utils_get_display_date:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Thu, 14 Jun 2007 13:34:32 +0000 (13:34 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Thu, 14 Jun 2007 13:34:32 +0000 (13:34 +0000)
  - use the localized (%X) display date
* _modest_header_view_compact_header_cell_data
  - don't try to display the date when it's zero

pmo-trunk-r2233

src/modest-text-utils.c
src/widgets/modest-header-view-render.c

index 07ae71c..cb1a16e 100644 (file)
@@ -236,7 +236,6 @@ modest_text_utils_strftime(char *s, gsize max, const char *fmt, time_t timet)
         *   g_date_set_time_t (&date, timet);
         */
        localtime_r (&timet, &tm);
-
        return strftime(s, max, fmt, &tm);
 }
 
@@ -994,14 +993,13 @@ modest_text_utils_get_display_date (time_t date)
        
        now = time (NULL);
 
-       modest_text_utils_strftime (date_buf, BUF_SIZE, "%d/%m/%Y", date);
-       modest_text_utils_strftime (now_buf,  BUF_SIZE, "%d/%m/%Y",  now); /* today */
-/*     modest_text_utils_strftime (date_buf, BUF_SIZE, "%x", date); */
-/*     modest_text_utils_strftime (now_buf,  BUF_SIZE, "%x",  now); /\* today *\/ */
+       /* use the localized dates */
+       modest_text_utils_strftime (date_buf, BUF_SIZE, "%x", date); 
+       modest_text_utils_strftime (now_buf,  BUF_SIZE, "%x", now); 
        
        /* if this is today, get the time instead of the date */
        if (strcmp (date_buf, now_buf) == 0)
-               modest_text_utils_strftime (date_buf, BUF_SIZE, "%H:%M %P", date);
+               modest_text_utils_strftime (date_buf, BUF_SIZE, "%X", date);
        
        return g_strdup(date_buf);
 }
index b3bcbdb..de70f8f 100644 (file)
@@ -255,7 +255,14 @@ _modest_header_view_compact_header_cell_data  (GtkTreeViewColumn *column,  GtkCe
        g_object_set (G_OBJECT (recipient_cell), "markup", header, NULL);       
        set_common_flags (recipient_cell, flags);
 
-       tmp_date = modest_text_utils_get_display_date (date);
+       /* in some rare cases, mail might have no Date: field. it case,
+        * don't show the date, instead of bogus 1/1/1970
+        */
+       if (date)
+               tmp_date = modest_text_utils_get_display_date (date);
+       else
+               tmp_date = g_strdup ("");
+       
        display_date = g_strdup_printf ("<small>%s</small>", tmp_date);
        g_object_set (G_OBJECT (date_cell), "markup", display_date, NULL);
        g_free (tmp_date);