diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-11-04 11:01:54 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-11-04 11:01:54 +0000 |
| commit | 1e4c231c0eabecf8723186dcea9a18692e7413e0 (patch) | |
| tree | f76c4012a9cd74f7b521251f30661d5767a9c391 /roundcubemail/program/include | |
| parent | 6943e74d258a5d6497a5544915bee1bfe2817f18 (diff) | |
- Fix handling of dates (birthday/anniversary) in contact data - don't convert them to users timezone (#1488147)
git-svn-id: https://svn.roundcube.net/trunk@5390 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include')
| -rw-r--r-- | roundcubemail/program/include/main.inc | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc index 3980794eb..7e31c012f 100644 --- a/roundcubemail/program/include/main.inc +++ b/roundcubemail/program/include/main.inc @@ -1018,15 +1018,15 @@ function rcube_strtotime($date) * 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 @@ function format_date($date, $format=NULL) if (empty($ts)) return ''; - // get user's timezone offset - $tz = $RCMAIL->config->get_timezone(); - - // convert time to user's timezone - $timestamp = $ts - date('Z', $ts) + ($tz * 3600); + if ($convert) { + // get user's timezone offset + $tz = $RCMAIL->config->get_timezone(); - // 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); + // convert time to user's timezone + $timestamp = $ts - date('Z', $ts) + ($tz * 3600); - $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']); + // 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; + } // 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; |
