diff --git a/CHANGELOG b/CHANGELOG index cfe53a2bd..f3c0fe82f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ CHANGELOG Roundcube Webmail - Fix regression where groups with email address were resolved to its members' addresses - Fix so group/addressbook selection is retained on page refresh - Fix bug where signature couldn't be added above the quote in Firefox 51 (#5628) +- Fix so microseconds macro (u) in log_date_format works (#1490446) RELEASE 1.1.7 ------------- diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 5f1b5f513..07828aa66 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1277,11 +1277,7 @@ class rcube $session_key = intval(self::$instance->config->get('log_session_id', 8)); } - if (empty($date_format)) { - $date_format = 'd-M-Y H:i:s O'; - } - - $date = date($date_format); + $date = rcube_utils::date_format($date_format); // trigger logging hook if (is_object(self::$instance) && is_object(self::$instance->plugins)) { diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 6780ed5cb..c64dfa838 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -1178,4 +1178,27 @@ class rcube_utils return $random; } + + /** + * Format current date according to specified format. + * This method supports microseconds (u). + * + * @param string $format Date format (default: 'd-M-Y H:i:s O') + * + * @return string Formatted date + */ + public static function date_format($format = null) + { + if (empty($format)) { + $format = 'd-M-Y H:i:s O'; + } + + if (strpos($format, 'u') !== false + && ($date = date_create_from_format('U.u.e', microtime(true) . '.' . date_default_timezone_get())) + ) { + return $date->format($format); + } + + return date($format); + } }