You are here

function dba_mysql_statpack_uptime in Database Administration 7

File

database/mysql.statpack.inc, line 3

Code

function dba_mysql_statpack_uptime($report) {
  $uptime = $report->uptime;
  $days = (int) ($uptime / 86400);
  $uptime %= 86400;
  $hours = (int) ($uptime / 3600);
  $uptime %= 3600;
  $minutes = (int) ($uptime / 60);
  $granularity = 0;
  $uptime = '';
  if ($days > 0 && $granularity < 2) {
    $uptime .= t('!days ', array(
      '!days' => format_plural($days, '1 day', '@count days'),
    ));
    $granularity++;
  }
  if ($hours > 0 && $granularity < 2) {
    $uptime .= t('!hours ', array(
      '!hours' => format_plural($hours, '1 hour', '@count hours'),
    ));
    $granularity++;
  }
  if ($minutes > 0 && $granularity < 2) {
    $uptime .= "{$minutes} mins ";
    $uptime .= t('!minutes ', array(
      '!minutes' => format_plural($minutes, '1 min', '@count mins'),
    ));
    $granularity++;
  }
  return $uptime;
}