|
|
|
@ -1020,20 +1020,21 @@ function rcube_strtotime($date)
|
|
|
|
|
*
|
|
|
|
|
* @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);
|
|
|
|
|
|
|
|
|
|
if (empty($ts))
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
|
|
if ($convert) {
|
|
|
|
|
// get user's timezone offset
|
|
|
|
|
$tz = $RCMAIL->config->get_timezone();
|
|
|
|
|
|
|
|
|
@ -1044,13 +1045,18 @@ function format_date($date, $format=NULL)
|
|
|
|
|
$now = time(); // local time
|
|
|
|
|
$now -= (int)date('Z'); // make GMT time
|
|
|
|
|
$now += ($tz * 3600); // user's time
|
|
|
|
|
$now_date = getdate($now);
|
|
|
|
|
}
|
|
|
|
|
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']);
|
|
|
|
|
|
|
|
|
|
// define date format depending on current time
|
|
|
|
|
if (!$format) {
|
|
|
|
|
if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now) {
|
|
|
|
|
$format = $RCMAIL->config->get('date_today', $RCMAIL->config->get('time_format', 'H:i'));
|
|
|
|
|
$today = true;
|
|
|
|
|