You are here

function date_field_all_day in Date 6.2

Same name and namespace in other branches
  1. 7.3 date.module \date_field_all_day()
  2. 7 date.module \date_field_all_day()
  3. 7.2 date.module \date_field_all_day()

Determine if a from/to date combination qualify as 'All day'.

Parameters

array $field, the field definition for this date field.:

object $date1, a date/time object for the 'from' date.:

object $date2, a date/time object for the 'to' date.:

Return value

TRUE or FALSE.

1 call to date_field_all_day()
theme_date_all_day in date/date.theme
Adjust from/to date format to account for 'all day'.

File

date/date.module, line 870
Defines date/time field types for the Content Construction Kit (CCK).

Code

function date_field_all_day($field, $date1, $date2 = NULL) {
  if (empty($date1) || !is_object($date1)) {
    return FALSE;
  }
  elseif (!date_has_time($field['granularity'])) {
    return TRUE;
  }
  if (empty($date2)) {
    $date2 = $date1;
  }
  $granularity = date_granularity_precision($field['granularity']);
  $increment = isset($field['widget']['increment']) ? $field['widget']['increment'] : 1;
  $date1 = date_format($date1, DATE_FORMAT_DATETIME);
  $date2 = date_format($date2, DATE_FORMAT_DATETIME);
  return date_is_all_day($date1, $date2, $granularity, $increment);
}