Skip to content

Commit

Permalink
[jan] Add parameters to Horde_Timezone_Zone#toVtimezone() to limit th…
Browse files Browse the repository at this point in the history
…e generated STANDARD and DAYLIGHT sections.
  • Loading branch information
yunosh committed Mar 23, 2016
1 parent 95f0a69 commit 3ae0f73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
18 changes: 16 additions & 2 deletions framework/Timezone/lib/Horde/Timezone/Zone.php
Expand Up @@ -77,7 +77,7 @@ public function add($info)
* this timezone.
* @throws Horde_Timezone_Exception
*/
public function toVtimezone()
public function toVtimezone($from = null, $to = null)
{
if (!count($this->_info)) {
throw new Horde_Timezone_Exception('No rules found for timezone ' . $this->_name);
Expand All @@ -95,8 +95,14 @@ public function toVtimezone()
$startDate = $this->_getDate(0);
$startOffset = $this->_getOffset(0);
for ($i = 1, $c = count($this->_info); $i < $c; $i++) {
if ($to && $startDate->after($to)) {
continue;
}
$name = $this->_info[$i][2];
$endDate = count($this->_info[$i]) > 3 ? $this->_getDate($i) : null;
if ($from && $endDate && $endDate->before($from)) {
continue;
}
if ($this->_info[$i][1] == '-') {
// Standard time.
$component = new Horde_Icalendar_Standard();
Expand All @@ -106,7 +112,15 @@ public function toVtimezone()
} else {
// Represented by a ruleset.
$startOffset = $this->_getOffset($i);
$this->_tz->getRule($this->_info[$i][1])->addRules($tz, $this->_name, $name, $startOffset, $startDate, $endDate);
$this->_tz->getRule($this->_info[$i][1])
->addRules(
$tz,
$this->_name,
$name,
$startOffset,
$from && $from->after($startDate) ? $from : $startDate,
$to && $to->before($endDate) ? $to : $endDate
);
$startDate = $endDate;
// Continue, because addRules() already adds the
// component to $tz.
Expand Down
16 changes: 8 additions & 8 deletions framework/Timezone/package.xml
Expand Up @@ -10,18 +10,18 @@
<email>jan@horde.org</email>
<active>yes</active>
</lead>
<date>2016-03-21</date>
<date>2016-03-23</date>
<version>
<release>1.0.12</release>
<api>1.0.0</api>
<release>1.1.0</release>
<api>1.1.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Add parameters to Horde_Timezone_Zone#toVtimezone() to limit the generated STANDARD and DAYLIGHT sections.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -318,15 +318,15 @@
</release>
<release>
<version>
<release>1.0.12</release>
<api>1.0.0</api></version>
<release>1.1.0</release>
<api>1.1.0</api></version>
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2016-03-21</date>
<date>2016-03-23</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Add parameters to Horde_Timezone_Zone#toVtimezone() to limit the generated STANDARD and DAYLIGHT sections.
</notes>
</release>
</changelog>
Expand Down

0 comments on commit 3ae0f73

Please sign in to comment.