I am importing events from an iCal feed and have managed to get everything working great except for events that take place all day. Currently they are coming in and defaulting to a xx/xx/xxxx 7:00pm to xx/xx +1/xxxx 7:00pm date when they should fall on the same day without a time. I've tried hardcoding 00:00:00 as the time but that get's ignored. I've also made sure that there are no default time settings on the field.
There is a checkbox for All Day but nothing seems to mark it as checked while I'm trying to create the node and it doesn't appear to be saved in the node object anywhere so not sure how I am suppose to set the checkbox while I'm creating the node.
Current code I am using while looping through each of the events in the feed:
// Use the UID to look up existing events.
if(!in_array($uid, $uids)){
if(strtotime($startDt->format ( 'm/d/Y h:ia' )) > strtotime("-1 month")){
try {
$node = new stdClass();
$node->type = "calendar_event";
$node->uid = 1;
$node->language = 'en';
$node->title = $eventName;
$node->body['und'][0]['value'] = stripslashes($eventLocation);
$node->body['und'][0]['format'] = 'full_html';
$node->field_uid['und'][0]['value'] = $uid;
$node->field_date['und'][0]['value'] = $startCom;
$node->field_date['und'][0]['value2'] = $endCom;
// this doesn't work
$node->field_date['und'][0]['all_day'] = 1;
$node->status = 1;
node_save($node);
$values = array(
'entity_type' => 'node',
'entity' => $node->nid,
'state' => OG_STATE_ACTIVE,
'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT,
'field_name' => 'og_group_ref'
);
og_group('node', $groupID, $values);
$newCount++;
} catch (Exception $e) {
watchdog_exception('school_calendar', $e);
}
}
} else { // uid existed, maybe we want to update if needed.
}