You are here

function _get_expiration_date in Ubercart 5

Function will return a expiration time stamp given a certain amount of time from a starting point (defaults to current time)

@return: A UNIX timestamp representing the second that expiration takes place

Parameters

$quantity: The amount of time until expiration

$granularity: A string representing the granularity's name (e.g. "day", "month", etc.)

$start_time: The starting date for when the role will last

3 calls to _get_expiration_date()
uc_roles_cron in uc_roles/uc_roles.module
Implementation of hook_cron().
uc_roles_order in uc_roles/uc_roles.module
Implementation of hook_order().
uc_roles_user in uc_roles/uc_roles.module
Implementation of hook_user().

File

uc_roles/uc_roles.module, line 1029
Grants roles upon accepted payment of products

Code

function _get_expiration_date($quantity, $granularity, $start_time = NULL) {
  if (empty($granularity)) {
    return NULL;
  }
  $start_time = !is_null($start_time) ? $start_time : time();
  $operator = $quantity < 0 ? '' : '+';
  return strtotime($operator . $quantity . ' ' . $granularity, $start_time);
}