You are here

function ca_condition_date in Ubercart 6.2

Check that the current time is within a specified range.

See also

ca_condition_date_form()

1 string reference to 'ca_condition_date'
ca_ca_condition in ca/ca.ca.inc
Implements hook_ca_condition().

File

ca/ca.ca.inc, line 120
This file includes some generic conditions and actions.

Code

function ca_condition_date($settings) {
  $set_date_start = mktime(0, 0, 0, $settings['date']['month'], $settings['date']['day'], $settings['date']['year']);
  $set_date_end = mktime(23, 59, 59, $settings['date']['month'], $settings['date']['day'], $settings['date']['year']);
  $curr_time = time();
  switch ($settings['operator']) {
    case 'before':
      return $curr_time < $set_date_start;
    case 'only':
      return $set_date_start < $curr_time && $curr_time < $set_date_end;
    case 'after':
      return $set_date_end < $curr_time;
    default:
      return FALSE;
  }
}