public function FeedsDateTime::setTimezone

cis7 FeedsParser.inc public FeedsDateTime::setTimezone($tz, $force = FALSE)
cle7 FeedsParser.inc public FeedsDateTime::setTimezone($tz, $force = FALSE)
elmsmedia7 FeedsParser.inc public FeedsDateTime::setTimezone($tz, $force = FALSE)
icor7 FeedsParser.inc public FeedsDateTime::setTimezone($tz, $force = FALSE)
meedjum_blog7 FeedsParser.inc public FeedsDateTime::setTimezone($tz, $force = FALSE)
mooc7 FeedsParser.inc public FeedsDateTime::setTimezone($tz, $force = FALSE)

Overrides default DateTime function. Only changes output values if actually had time granularity. This should be used as a "converter" for output, to switch tzs.

In order to set a timezone for a datetime that doesn't have such granularity, merge() it with one that does.

1 call to FeedsDateTime::setTimezone()
FeedsDateTime::__construct in sites/all/modules/ulmus/feeds/plugins/FeedsParser.inc
Overridden constructor.

File

sites/all/modules/ulmus/feeds/plugins/FeedsParser.inc, line 654
Contains FeedsParser and related classes.

Class

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

Code

public function setTimezone($tz, $force = FALSE) {
  // PHP 5.2.6 has a fatal error when setting a date's timezone to itself.
  // http://bugs.php.net/bug.php?id=45038
  if (version_compare(PHP_VERSION, '5.2.7', '<') && $tz == $this->getTimezone()) {
    $tz = new DateTimeZone($tz->getName());
  }

  if (!$this->hasTime() || !$this->hasGranularity('zone') || $force) {
    // this has no time or timezone granularity, so timezone doesn't mean much
    // We set the timezone using the method, which will change the day/hour, but then we switch back
    $arr = $this->toArray();
    parent::setTimezone($tz);
    $this->setDate($arr['year'], $arr['month'], $arr['day']);
    $this->setTime($arr['hour'], $arr['minute'], $arr['second']);
    return;
  }
  parent::setTimezone($tz);
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.