[Svn] r5390 - in trunk/roundcubemail: . program/include program/steps/addressbook

trac at roundcube.net trac at roundcube.net
Fri Nov 4 12:01:54 CET 2011


Author: alec
Date: 2011-11-04 06:01:54 -0500 (Fri, 04 Nov 2011)
New Revision: 5390

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/main.inc
   trunk/roundcubemail/program/steps/addressbook/func.inc
Log:
- Fix handling of dates (birthday/anniversary) in contact data - don't convert them to users timezone (#1488147)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2011-11-04 09:08:54 UTC (rev 5389)
+++ trunk/roundcubemail/CHANGELOG	2011-11-04 11:01:54 UTC (rev 5390)
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix handling of dates (birthday/anniversary) in contact data (#1488147)
 - Fix error on opening searched LDAP contact (#1488144)
 - Fix redundant line break in flowed format (#1488146)
 - TinyMCE:

Modified: trunk/roundcubemail/program/include/main.inc
===================================================================
--- trunk/roundcubemail/program/include/main.inc	2011-11-04 09:08:54 UTC (rev 5389)
+++ trunk/roundcubemail/program/include/main.inc	2011-11-04 11:01:54 UTC (rev 5390)
@@ -1018,15 +1018,15 @@
  * Convert the given date to a human readable form
  * This uses the date formatting properties from config
  *
- * @param mixed Date representation (string or timestamp)
+ * @param mixed  Date representation (string or timestamp)
  * @param string Date format to use
+ * @param bool   Enables date convertion according to user timezone
+ *
  * @return string Formatted date string
  */
-function format_date($date, $format=NULL)
+function format_date($date, $format=NULL, $convert=true)
 {
   global $RCMAIL, $CONFIG;
-  
-  $ts = NULL;
 
   if (!empty($date))
     $ts = rcube_strtotime($date);
@@ -1034,23 +1034,29 @@
   if (empty($ts))
     return '';
 
-  // get user's timezone offset
-  $tz = $RCMAIL->config->get_timezone();
+  if ($convert) {
+    // get user's timezone offset
+    $tz = $RCMAIL->config->get_timezone();
 
-  // convert time to user's timezone
-  $timestamp = $ts - date('Z', $ts) + ($tz * 3600);
+    // convert time to user's timezone
+    $timestamp = $ts - date('Z', $ts) + ($tz * 3600);
 
-  // get current timestamp in user's timezone
-  $now = time();  // local time
-  $now -= (int)date('Z'); // make GMT time
-  $now += ($tz * 3600); // user's time
-  $now_date = getdate($now);
+    // get current timestamp in user's timezone
+    $now = time();  // local time
+    $now -= (int)date('Z'); // make GMT time
+    $now += ($tz * 3600); // user's time
+  }
+  else {
+    $now       = time();
+    $timestamp = $ts;
+  }
 
-  $today_limit = mktime(0, 0, 0, $now_date['mon'], $now_date['mday'], $now_date['year']);
-  $week_limit  = mktime(0, 0, 0, $now_date['mon'], $now_date['mday']-6, $now_date['year']);
-
   // define date format depending on current time
   if (!$format) {
+    $now_date    = getdate($now);
+    $today_limit = mktime(0, 0, 0, $now_date['mon'], $now_date['mday'], $now_date['year']);
+    $week_limit  = mktime(0, 0, 0, $now_date['mon'], $now_date['mday']-6, $now_date['year']);
+
     if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now) {
       $format = $RCMAIL->config->get('date_today', $RCMAIL->config->get('time_format', 'H:i'));
       $today  = true;

Modified: trunk/roundcubemail/program/steps/addressbook/func.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/func.inc	2011-11-04 09:08:54 UTC (rev 5389)
+++ trunk/roundcubemail/program/steps/addressbook/func.inc	2011-11-04 11:01:54 UTC (rev 5390)
@@ -624,7 +624,7 @@
                                 $RCMAIL->output->set_env('month_names', $month_names);
                             }
                             $colprop['class'] .= ($colprop['class'] ? ' ' : '') . 'datepicker';
-                            $val = format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'));
+                            $val = format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'), false);
                         }
 
                         $val = rcmail_get_edit_field($col, $val, $colprop, $colprop['type']);
@@ -733,7 +733,7 @@
 function rcmail_format_date_col($val)
 {
     global $RCMAIL;
-    return format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'));
+    return format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'), false);
 }
 
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list