You are here

function dblog_common_format_minutes in Util 6.3

Same name and namespace in other branches
  1. 6.2 contribs/dblog_ext/dblog_common.module \dblog_common_format_minutes()
1 call to dblog_common_format_minutes()
dblog_filters_log_filters in contribs/dblog_ext/dblog_filters/dblog_time_filters.module
Implementation of hook_log_filters() on behalf of dblog.

File

contribs/dblog_ext/dblog_common.module, line 3

Code

function dblog_common_format_minutes($minutes, $recent) {
  $hours = (int) ($minutes / 60);
  $minutes = $minutes % 60;
  $half_hour = $minutes == 30;
  $time = '';
  if ($hours) {
    $time .= format_plural($hours, 'hour', '@count hours') . ' ';
  }
  if ($half_hour) {
    $time .= $hours ? t('and a half') : t('half hour');
  }
  elseif ($minutes) {
    if ($hours) {
      $time .= t('and') . ' ';
    }
    $time .= format_plural($minutes, empty($time) ? 'minute' : '1 minute', '@count minutes');
  }
  $args = array(
    '!time' => $time,
  );
  return $recent ? t('within the last !time', $args) : t('beyond the last !time', $args);
}