You are here

protected function FeedsDateTime::setGranularityFromTime in Feeds 8.2

Protected function to find the granularity given by the arguments to the constructor.

1 call to FeedsDateTime::setGranularityFromTime()
FeedsDateTime::__construct in lib/Drupal/feeds/FeedsDateTime.php
Overridden constructor.

File

lib/Drupal/feeds/FeedsDateTime.php, line 177

Class

FeedsDateTime
Extend PHP DateTime class with granularity handling, merge functionality and slightly more flexible initialization parameters.

Namespace

Drupal\feeds

Code

protected function setGranularityFromTime($time, $tz) {
  $this->granularity = array();
  $temp = date_parse($time);

  // This PHP method currently doesn't have resolution down to seconds, so if
  // there is some time, all will be set.
  foreach (self::$allgranularity as $g) {
    if (isset($temp[$g]) && is_numeric($temp[$g]) || $g == 'zone' && (isset($temp['zone_type']) && $temp['zone_type'] > 0)) {
      $this->granularity[] = $g;
    }
  }
  if ($tz) {
    $this
      ->addGranularity('zone');
  }
}