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 a0e0f417c5859fae8321cba14c370759796d4706..c776b787b3b41762dd7007c911219a096c48266b 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 5cc697495f3430a7a898d08ce05fc8eba2ac7690..c3d5f56d3be2a44673fc2d11c2cd1b9b44e1fc02 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 a5f1c7774a68314bbb5931366a4ea9d008fbe27d..85a0c29964ded1c43d6c2c56a68c366b30189156 100644 (file)
@@ -286,6 +286,15 @@ function load_optpage_data_display() {
         'refresh' => SMOPT_REFRESH_NONE
     );
 
+    $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)"),