From: Chuck Hagenbuch Date: Mon, 26 Jan 2009 02:40:23 +0000 (-0500) Subject: initial php version of Span.php X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=170a321ddd9534e3906315702e766a9f835f7f90;p=horde.git initial php version of Span.php --- diff --git a/framework/Date_Parser/lib/Horde/Date/Span.php b/framework/Date_Parser/lib/Horde/Date/Span.php index d61c24cc0..c2de84b5a 100644 --- a/framework/Date_Parser/lib/Horde/Date/Span.php +++ b/framework/Date_Parser/lib/Horde/Date/Span.php @@ -1,27 +1,48 @@ +begin = $begin; + $this->end = $end; + } - # Subtract a number of seconds to this span, returning the - # resulting Span - def -(seconds) - self + -seconds - end + /** + * Return the width of this span in seconds + */ + public function width() + { + return $this->end - $this->begin; + } - # Prints this span in a nice fashion - def to_s - '(' << self.begin.to_s << '..' << self.end.to_s << ')' - end - end + /** + * Add a number of seconds to this span, returning the new span + */ + public function add($seconds) + { + return new Horde_Date_Span($this->begin + $seconds, $this->end + $seconds); + } + /** + * Subtract a number of seconds from this span, returning the new span. + */ + public function sub($seconds) + { + return $this->add(-$seconds); + } + + public function __toString() + { + return '(' . $this->begin . '..' . $this->end . ')'; + } + +}