You are here

function password_policy_parse_interval in Password Policy 7.2

Helper function to get number of seconds represented by relative time string.

Parameters

string $string: The time interval string to parse - like 20 minutes or 4 weeks.

bool $report_errors: Whether or not to set a message if the string can't be parsed.

Return value

int Number of seconds in the interval

2 calls to password_policy_parse_interval()
PasswordPolicyExpire::cron in plugins/item/expire.inc
Cron task for expiration plugin.
PasswordPolicyExpire::init in plugins/item/expire.inc
Checks on init if the user password has expired.

File

./password_policy.module, line 503
Enforces password policies.

Code

function password_policy_parse_interval($string, $report_errors = FALSE) {
  $int = strtotime($string, 0);
  if ($report_errors && $int === FALSE) {
    drupal_set_message(t("Unable to parse time interval. Please use something like '1 day' or 2 weeks'."), 'error');
  }
  return $int;
}