You are here

function _uc_role_get_expiration in Ubercart 8.4

Returns an expiration time stamp given a period of time.

Parameters

int $duration: The amount of time until expiration.

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

int $start_time: (optional) The starting date for when the role will last. Defaults to the current time.

Return value

int|null A UNIX timestamp representing the second that expiration takes place, or NULL if the expiration should never occur.

5 calls to _uc_role_get_expiration()
RenewRole::getExpiration in uc_role/src/Plugin/RulesAction/RenewRole.php
Calculates the expiration time using a role_product object.
RoleFeatureForm::buildForm in uc_role/src/Form/RoleFeatureForm.php
Form constructor.
uc_role_cron in uc_role/uc_role.module
Implements hook_cron().
uc_role_user_presave in uc_role/uc_role.module
Implements hook_user_presave().
uc_role_user_validate in uc_role/uc_role.module
User profile form validate handler.

File

uc_role/uc_role.module, line 698
Grants roles upon accepted payment of products.

Code

function _uc_role_get_expiration($duration, $granularity, $start_time = NULL) {

  // Never expires?
  if ($granularity == 'never') {
    return NULL;
  }
  $start_time = !is_null($start_time) ? $start_time : \Drupal::time()
    ->getRequestTime();
  $operator = $duration < 0 ? '' : '+';
  return strtotime($operator . $duration . ' ' . $granularity, $start_time);
}