You are here

protected function FeedsDateTime::setGranularityFromTime in Feeds 7.2

Same name and namespace in other branches
  1. 6 plugins/FeedsParser.inc \FeedsDateTime::setGranularityFromTime()
  2. 7 plugins/FeedsParser.inc \FeedsDateTime::setGranularityFromTime()

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

1 call to FeedsDateTime::setGranularityFromTime()
FeedsDateTime::__construct in plugins/FeedsParser.inc
Overridden constructor.

File

plugins/FeedsParser.inc, line 894
Contains FeedsParser and related classes.

Class

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

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');
  }
}