You are here

function _format_interval in Inactive User 5

Same name and namespace in other branches
  1. 6 inactive_user.module \_format_interval()

Slighty modified from format_interval() in common.inc to include months

1 call to _format_interval()
_inactive_user_mail in ./inactive_user.module
Wrapper for user_mail
1 string reference to '_format_interval'
inactive_user_custom_settings in ./inactive_user.module
Custom settings page: menu callback (we're using a custom callback to enable a nicer menu title, without underscore

File

./inactive_user.module, line 397

Code

function _format_interval($timestamp, $granularity = 2) {
  $units = array(
    '1 year|@count years' => 31536000,
    '1 month|@count months' => 2592000,
    '1 week|@count weeks' => 604800,
    '1 day|@count days' => 86400,
    '1 hour|@count hours' => 3600,
    '1 min|@count min' => 60,
    '1 sec|@count sec' => 1,
  );
  foreach ($units as $key => $value) {
    $key = explode('|', $key);
    if ($timestamp >= $value) {
      $output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1]);
      $timestamp %= $value;
      $granularity--;
    }
    if ($granularity == 0) {
      break;
    }
  }
  return $output ? $output : t('0 sec');
}