Simplify date display
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 16 Mar 2009 20:41:55 +0000 (14:41 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 16 Mar 2009 20:41:55 +0000 (14:41 -0600)
imp/js/src/DimpBase.js
imp/lib/UI/Message.php
imp/lib/Views/ShowMessage.php
imp/message-mimp.php
imp/message.php
imp/thread.php

index 040c79d..7e45077 100644 (file)
@@ -941,7 +941,7 @@ var DimpBase = {
 
         // Add date
         $('msgHeadersColl').select('.date').invoke('update', r.minidate);
-        $('msgHeaderDate').select('.date').invoke('update', r.fulldate);
+        $('msgHeaderDate').select('.date').invoke('update', r.localdate);
 
         // Add from/to/cc headers
         [ 'from', 'to', 'cc' ].each(function(a) {
index f916b7f..b507519 100644 (file)
@@ -106,11 +106,9 @@ class IMP_UI_Message
      *
      * @param string $date  The date string.
      *
-     * @return string  The date string with the local time added on. If not
-     *                 in MIMP mode, the output has been run through
-     *                 htmlspecialchars().
+     * @return string  The local formatted time string.
      */
-    public function addLocalTime($date)
+    public function getLocalTime($date)
     {
         if (empty($date)) {
             $ltime = false;
@@ -120,9 +118,7 @@ class IMP_UI_Message
         }
 
         if (($ltime === false) || ($ltime === -1)) {
-            return ($_SESSION['imp']['view'] == 'mimp')
-                ? $date
-                : htmlspecialchars($date);
+            return '';
         }
 
         $time_str = strftime($GLOBALS['prefs']->getValue('time_format'), $ltime);
@@ -133,15 +129,11 @@ class IMP_UI_Message
             (date('d') != @date('d', $ltime))) {
             /* Not today, use the date. */
             $date_str = strftime($GLOBALS['prefs']->getValue('date_format'), $ltime);
-            $local_date = sprintf('[%s %s %s]', $date_str, $time_str, $tz);
-        } else {
-            /* Else, it's today, use the time only. */
-            $local_date = sprintf('[%s %s]', $time_str, $tz);
+            return sprintf('%s %s %s', $date_str, $time_str, $tz);
         }
 
-        return ($_SESSION['imp']['view'] == 'mimp')
-            ? $date . ' ' . $local_date
-            : htmlspecialchars($date) . ' <small>' . htmlspecialchars($local_date) . '</small>';
+        /* Else, it's today, use the time only. */
+        return sprintf('%s %s', $time_str, $tz);
     }
 
     /**
index 75b504a..53daf40 100644 (file)
@@ -180,9 +180,9 @@ class IMP_Views_ShowMessage
             } elseif ($val = $mime_headers->getValue($head)) {
                 if ($head == 'date') {
                     /* Add local time to date header. */
-                    $val = nl2br($imp_ui->addLocalTime($envelope['date']));
+                    $val = htmlspecialchars($imp_ui->getLocalTime($envelope['date']));
                     if ($preview) {
-                        $result['fulldate'] = $val;
+                        $result['localdate'] = $val;
                     }
                 } elseif (!$preview) {
                     $val = htmlspecialchars($val);
index c40c6aa..69c6fcc 100644 (file)
@@ -160,7 +160,7 @@ $user_identity = &Identity::singleton(array('imp', 'imp'));
 $basic_headers = $imp_ui->basicHeaders();
 $display_headers = $msgAddresses = array();
 
-$format_date = $imp_ui->addLocalTime(nl2br($envelope['date']));
+$format_date = $imp_ui->getLocalTime($envelope['date']);
 if (!empty($format_date)) {
     $display_headers['date'] = $format_date;
 }
index 4ee6658..156bdcd 100644 (file)
@@ -237,7 +237,7 @@ $imp_ui = new IMP_UI_Message();
 $basic_headers = $imp_ui->basicHeaders();
 $display_headers = $msgAddresses = array();
 
-$format_date = $imp_ui->addLocalTime(nl2br($envelope['date']));
+$format_date = $imp_ui->getLocalTime($envelope['date']);
 if (!empty($format_date)) {
     $display_headers['date'] = $format_date;
 }
index 2c09920..4abf24e 100644 (file)
@@ -100,7 +100,7 @@ foreach ($loop_array as $mbox => $idxlist) {
         $curr_msg['idx'] = $idx;
 
         /* Get headers for the message. */
-        $curr_msg['date'] = $imp_ui->addLocalTime(nl2br($envelope['date']));
+        $curr_msg['date'] = $imp_ui->getLocalTime($envelope['date']);
 
         if (IMP::isSpecialFolder($mbox)) {
             $curr_msg['addr_to'] = true;