Add new 'Custom Date Format' option for message list date format
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 14 Mar 2008 08:43:30 +0000 (08:43 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 14 Mar 2008 08:43:30 +0000 (08:43 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13035 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/date.php
include/load_prefs.php
include/options/display.php

index a0e0f41..c776b78 100644 (file)
@@ -291,11 +291,12 @@ function date_intl( $date_format, $stamp ) {
     $ret = date('w#m#'. $ret, $stamp );
     // extract day and month in order to replace later by intl day and month
     $aParts = explode('#',$ret);
-    $ret = str_replace(array('$1','$4','$2','$3',), array(getDayAbrv($aParts[0]),
-                                                          getMonthAbrv($aParts[1]),
-                                                          getMonthName($aParts[1]),
-                                                          getDayName($aParts[0])),
-                                                          $aParts[2]);
+    $ret = str_replace(array('$1','$4','$2','$3',), 
+                       array(getDayAbrv($aParts[0]),
+                             getMonthAbrv($aParts[1]),
+                             getMonthName($aParts[1]),
+                             getDayName($aParts[0])),
+                       $aParts[2]);
     return( $ret );
 }
 
@@ -338,7 +339,7 @@ function getLongDateString( $stamp, $fallback = '' ) {
  */
 function getDateString( $stamp ) {
 
-    global $invert_time, $hour_format, $show_full_date;
+    global $invert_time, $hour_format, $show_full_date, $custom_date_format;
 
     if ( $stamp == -1 ) {
        return '';
@@ -364,7 +365,10 @@ function getDateString( $stamp ) {
     }
     $nextmid = $midnight + 86400;
 
-    if (($show_full_date == 1) || ($nextmid < $stamp)) {
+    $custom_date_format = trim($custom_date_format);
+    if (!empty($custom_date_format)) {
+        $date_format = $custom_date_format;
+    } else if ($show_full_date == 1 || $nextmid < $stamp) {
         $date_format = _("M j, Y");
     } else if ($midnight < $stamp) {
         /* Today */
index 5cc6974..c3d5f56 100644 (file)
@@ -323,6 +323,7 @@ $mailbox_select_style = getPref($data_dir, $username, 'mailbox_select_style', SM
 
 /* Allow user to customize, and display the full date, instead of day, or time based
    on time distance from date of message */
+$custom_date_format = getPref($data_dir, $username, 'custom_date_format', '');
 $show_full_date = getPref($data_dir, $username, 'show_full_date', SMPREF_OFF);
 
 /* Allow user to customize length of from field */
index a5f1c77..85a0c29 100644 (file)
@@ -287,6 +287,15 @@ function load_optpage_data_display() {
     );
 
     $optvals[SMOPT_GRP_MAILBOX][] = array(
+        'name'          => 'custom_date_format',
+        'caption'       => _("Custom Date Format"),
+        'trailing_text' => ' ' . _("(Uses format of PHP date() function)"),
+        'type'          => SMOPT_TYPE_STRING,
+        'refresh'       => SMOPT_REFRESH_NONE,
+        'size'          => SMOPT_SIZE_TINY,
+    );
+
+    $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'truncate_sender',
         'caption' => _("Length of From/To Field (0 for full)"),
         'type'    => SMOPT_TYPE_INTEGER,