You are here

public function NodeRegistrationNodeSettings::time_from_date_field in Node registration 7

Retrieves the time for a given date field in this node.

2 calls to NodeRegistrationNodeSettings::time_from_date_field()
NodeRegistrationNodeSettings::max_registration_time in includes/node_registration.node_settings.inc
Retrieves the maximum registration time for this event.
NodeRegistrationNodeSettings::min_registration_time in includes/node_registration.node_settings.inc
Retrieves the minimum registration time for this event.

File

includes/node_registration.node_settings.inc, line 137
Node settings class.

Class

NodeRegistrationNodeSettings
Node settings class.

Code

public function time_from_date_field($date_field) {
  if ($date_field) {
    list($date_field, $column) = explode(':', $date_field . ':value');
    $items = field_get_items('node', $this->node, $date_field);
    if ($items) {
      $item = $items[0];

      // I stole the next part from date_tokens().
      $date = new DateObject($item[$column], $item['timezone_db'], date_type_format($item['date_type']));
      if ($date && $item['timezone_db'] != $item['timezone']) {
        date_timezone_set($date, timezone_open($item['timezone']));
      }
      $utc = $date ? (int) date_format_date($date, 'custom', 'U') : 0;

      // That part.
      return $utc;
    }
  }

  // Not NULL, for caching/isset purposes.
  return FALSE;
}