Skip to content

Commit

Permalink
Support obtaining the station's gmt offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Mar 28, 2014
1 parent 4ea6424 commit bb8c518
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion framework/Service_Weather/lib/Horde/Service/Weather/Station.php
Expand Up @@ -23,7 +23,8 @@
* @property string state The state.
* @property string country The country's iso3166 name (if available).
* @property string country_name The country's common name.
* @property string tz The timezone name (if available).
* @property mixed tz The timezone name, or offset from UTC
* depending on the API. @see self::getOffset()
* @property string lat The lattitude (if available).
* @property string lon The longitude (if available).
* @property string zip The postal code.
Expand Down Expand Up @@ -51,4 +52,23 @@ public function __set($property, $value)
$this->_properties[$property] = $value;
}

/**
* Return the CURRENT offset from UTC for this station as provided by the
* API.
*
* @return integer The current offset from UTC.
* @since 1.2.0
*/
public function getOffset()
{
if (!empty($this->tz) && is_string($this->tz)) {
$d = new Horde_Date(time(), 'UTC');
$d->setTimezone($this->tz);
return $d->tzOffset();
} elseif (!empty($this->tz)) {
// tz is provided as an offset already.
return $this->tz;
}
}

}

0 comments on commit bb8c518

Please sign in to comment.