*/
class IMP_Ui_Mailbox
{
+ const DATE_FORCE = 1;
+ const DATE_FULL = 2;
+
/**
* The current mailbox.
*
/**
* Formats the date header.
*
- * @param integer $date The UNIX timestamp.
+ * @param integer $date The UNIX timestamp.
+ * @param integer $format Mask of formatting options:
+ * <pre>
+ * IMP_Mailbox_Ui::DATE_FORCE - Force use of date formatting, instead of
+ * time formatting, for all dates.
+ * IMP_Mailbox_Ui::DATE_FULL - Use full representation of date, including
+ * time information.
+ * </pre>
*
* @return string The formatted date header.
*/
- public function getDate($date)
+ public function getDate($date, $format = 0)
{
if (empty($date)) {
return _("Unknown Date");
}
- if (!isset($this->_cache['today_start'])) {
- $this->_cache['today_start'] = strtotime('today');
- $this->_cache['today_end'] = strtotime('today + 1 day');
+ if (!($format & self::DATE_FORCE) &&
+ !isset($this->_cache['today_start'])) {
+ $this->_cache['today_start'] = new DateTime('today');
+ $this->_cache['today_end'] = new DateTime('today + 1 day');
}
try {
}
$udate = $d->format('U');
- if (($udate < $this->_cache['today_start']) ||
- ($udate > $this->_cache['today_end'])) {
+ if (($format & self::DATE_FORCE) ||
+ ($udate < $this->_cache['today_start']->format('U')) ||
+ ($udate > $this->_cache['today_end']->format('U'))) {
/* Not today, use the date. */
- return strftime($GLOBALS['prefs']->getValue('date_format'), $udate);
+ if ($format & self::DATE_FULL) {
+ return strftime($GLOBALS['prefs']->getValue('date_format'), $udate) .
+ ' [' . strftime($GLOBALS['prefs']->getValue('time_format'), $udate) . ']';
+ }
+
+ return strftime($GLOBALS['prefs']->getValue('date_format_mini'), $udate);
}
/* Else, it's today, use the time. */
$headers = array();
foreach ($basic_headers as $key => $val) {
if ($hdr_val = $headerob->getValue($key)) {
+ /* Format date string. */
+ if ($key == 'date') {
+ $imp_ui_mbox = new IMP_Ui_Mailbox();
+ $hdr_val = $imp_ui_mbox->getDate($hdr_val, IMP_Ui_Mailbox::DATE_FORCE | IMP_Ui_Mailbox::DATE_FULL);
+ }
+
$headers[] = array(
'header' => htmlspecialchars($val),
'value' => htmlspecialchars($hdr_val)