From: Chuck Hagenbuch Date: Mon, 2 Feb 2009 19:21:01 +0000 (-0500) Subject: wire up Horde_Date_Span X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=12557455604f1f485d3306a41d91dba00a39364d;p=horde.git wire up Horde_Date_Span --- diff --git a/framework/Date_Parser/lib/Horde/Date/Span.php b/framework/Date_Parser/lib/Horde/Date/Span.php index c2de84b5a..bfd28f7ca 100644 --- a/framework/Date_Parser/lib/Horde/Date/Span.php +++ b/framework/Date_Parser/lib/Horde/Date/Span.php @@ -1,13 +1,23 @@ end - $this->begin; + return $this->end->timestamp() - $this->begin->timestamp(); } /** * Add a number of seconds to this span, returning the new span */ - public function add($seconds) + public function add($factor) { - return new Horde_Date_Span($this->begin + $seconds, $this->end + $seconds); + $b = clone($this->begin); + $e = clone($this->end); + if (is_array($factor)) { + foreach ($factor as $property => $value) { + $b->$property += $value; + $e->$property += $value; + } + } else { + $b->sec += $factor; + $e->sec += $factor; + } + return new Horde_Date_Span($b, $e); } /** * Subtract a number of seconds from this span, returning the new span. */ - public function sub($seconds) + public function sub($factor) { - return $this->add(-$seconds); + if (is_array($factor)) { + foreach ($factor as &$value) { + $value *= -1; + } + } else { + $factor *= -1; + } + + return $this->add($factor); } public function __toString()