alecpl
2011-02-10 de3dde7f2cfb6a11930b9f6588a2a759821f1f4f
- Support strftime format in date_today option


2 files modified
18 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/main.inc 17 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Support strftime format in date_today option
- Fix handling of attachments with invalid content type (#1487767)
- Add workaround for DBMail's bug http://www.dbmail.org/mantis/view.php?id=881 (#1487766)
- Use IMAP's ID extension (RFC2971) to print more info into debug log
program/include/main.inc
@@ -1074,8 +1074,10 @@
  // define date format depending on current time
  if (!$format) {
    if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now)
      return sprintf('%s %s', rcube_label('today'), date($CONFIG['date_today'] ? $CONFIG['date_today'] : 'H:i', $timestamp));
    if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now) {
      $format = $CONFIG['date_today'] ? $CONFIG['date_today'] : 'H:i';
      $today  = true;
    }
    else if ($CONFIG['prettydate'] && $timestamp > $week_limit && $timestamp < $now)
      $format = $CONFIG['date_short'] ? $CONFIG['date_short'] : 'D H:i';
    else
@@ -1083,14 +1085,15 @@
    }
  // strftime() format
  if (preg_match('/%[a-z]+/i', $format))
    return strftime($format, $timestamp);
  if (preg_match('/%[a-z]+/i', $format)) {
    $format = strftime($format, $timestamp);
    return $today ? (rcube_label('today') . ' ' . $format) : $format;
  }
  // parse format string manually in order to provide localized weekday and month names
  // an alternative would be to convert the date() format string to fit with strftime()
  $out = '';
  for($i=0; $i<strlen($format); $i++)
    {
  for($i=0; $i<strlen($format); $i++) {
    if ($format{$i}=='\\')  // skip escape chars
      continue;
    
@@ -1115,7 +1118,7 @@
      $out .= date($format{$i}, $timestamp);
    }
  
  return $out;
  return $today ? (rcube_label('today') . ' ' . $out) : $out;
  }