You are here

function _signup_date_format_date in Signup 7

Same name and namespace in other branches
  1. 5.2 includes/date.5x-2.inc \_signup_date_format_date()
  2. 5.2 includes/date.5x-1.inc \_signup_date_format_date()
  3. 6.2 includes/date.inc \_signup_date_format_date()
  4. 6 includes/date.inc \_signup_date_format_date()
1 call to _signup_date_format_date()
signup_format_date in includes/scheduler.inc
@todo Please document this function.

File

includes/date.inc, line 483
Code to support using CCK date fields for time-based signup functionality.

Code

function _signup_date_format_date($node, $include_to_date = FALSE) {
  $field = signup_date_field($node->type);
  if (!$field || $field == 'none') {
    return '';
  }
  if ($field['settings']['tz_handling'] == 'date') {
    if (isset($node->{$field['field_name']})) {
      $tz = $node->{$field['field_name']}[$node->language][0]['timezone'];
    }
    else {
      $tz = $node->{$field['field_name'] . '_timezone'};
    }
  }
  else {
    $tz = date_default_timezone();
  }
  $display_tz = date_get_timezone($field['settings']['tz_handling'], $tz);
  $db_tz = date_get_timezone_db($field['settings']['tz_handling'], $tz);
  if (isset($node->{$field['field_name']})) {
    $date_value = $node->{$field['field_name']}[$node->language][0]['value'];
  }
  else {
    $date_value = $node->{$field['field_name'] . '_value'};
  }
  $date = new DateObject($date_value, $db_tz, NULL);
  if ($db_tz != $display_tz) {
    $date
      ->setTimezone(timezone_open($display_tz));
  }
  $format = date_formatter_format('default', $field['field_name']);
  $date_out = $date
    ->format($format);
  if ($include_to_date) {
    if (isset($node->{$field['field_name']})) {
      $date_value = $node->{$field['field_name']}[$node->language][0]['value2'];
    }
    else {
      $date_value = $node->{$field['field_name'] . '_value2'};
    }
    $date = new DateObject($date_value, $db_tz, $field['type']);
    if ($db_tz != $display_tz) {
      $date
        ->setTimezone(timezone_open($display_tz));
    }

    //@TODO: shouldn't this be $date_out?
    $date = $date
      ->format($format);
    if ($date_value) {
      $date = new DateObject($date_value);
      $date_out .= t(' to ') . $date
        ->format($format);
    }
  }
  return $date_out;
}