function _ws_datefield_populate_datetime_field_data in Web Service Data 7
Build the field array
2 calls to _ws_datefield_populate_datetime_field_data()
- ws_datefield_wsfields_datetime2_data_alter in modules/
ws_datefield/ ws_datefield.module - Implements hook_wsfields_FIELD_TYPE_data_alter().
- _ws_datefield_map_datetime in modules/
ws_datefield/ ws_datefield.module - Map the data values to their address field containers
File
- modules/
ws_datefield/ ws_datefield.module, line 52 - Main module for ws_datefields
Code
function _ws_datefield_populate_datetime_field_data(&$field_data, &$value, $repeat = FALSE, $end_date = FALSE, $language = LANGUAGE_NONE) {
$value['value']
->setTimezone(new DateTimeZone('UTC'));
if (isset($value['value2'])) {
$value['value2']
->setTimezone(new DateTimeZone('UTC'));
}
$field_data[$language][] = array(
'value' => $value['value']
->format(WS_DATEFIELD_DATE_VALUE_FORMAT),
'timezone' => $value['value']
->getTimezone()
->getName(),
'offset' => $value['value']
->getOffset(),
);
// Check for the repeat rule
if ($repeat and isset($value['rrule'])) {
// Since we're always adding to the end of the array, we can just use count -1
$field_data[$language][count($field_data[$language]) - 1]['rrule'] = $value['rrule'];
}
// Check for an end date
if ($end_date and isset($value['value2'])) {
// Since we're always adding to the end of the array, we can just use count -1
$field_data[$language][count($field_data[$language]) - 1]['value2'] = $value['value2']
->format(WS_DATEFIELD_DATE_VALUE_FORMAT);
}
}