You are here

protected static function FeedsDateTimeElement::readDateField in Feeds 8.2

Helper method for buildDateField(). Build a FeedsDateTimeElement object from a standard formatted node.

1 call to FeedsDateTimeElement::readDateField()
FeedsDateTimeElement::buildDateField in lib/Drupal/feeds/FeedsDateTimeElement.php
Build a entity's date field from our object.

File

lib/Drupal/feeds/FeedsDateTimeElement.php, line 78

Class

FeedsDateTimeElement
Defines a date element of a parsed result (including ranges, repeat).

Namespace

Drupal\feeds

Code

protected static function readDateField($entity, $field_name, $delta = 0) {
  $ret = new FeedsDateTimeElement();
  if (isset($entity->{$field_name}['und'][$delta]['date']) && $entity->{$field_name}['und'][$delta]['date'] instanceof FeedsDateTime) {
    $ret->start = $entity->{$field_name}['und'][$delta]['date'];
  }
  if (isset($entity->{$field_name}['und'][$delta]['date2']) && $entity->{$field_name}['und'][$delta]['date2'] instanceof FeedsDateTime) {
    $ret->end = $entity->{$field_name}['und'][$delta]['date2'];
  }
  return $ret;
}