From 4ada86876033fa171e2896d7e3d3c5645d8062db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:46:47 +0200 Subject: Adding upstream version 0.10.0. Signed-off-by: Daniel Baumann --- library/Reporting/Timeframe.php | 168 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 library/Reporting/Timeframe.php (limited to 'library/Reporting/Timeframe.php') diff --git a/library/Reporting/Timeframe.php b/library/Reporting/Timeframe.php new file mode 100644 index 0000000..f295779 --- /dev/null +++ b/library/Reporting/Timeframe.php @@ -0,0 +1,168 @@ +getDb(); + + $select = (new Select()) + ->from('timeframe') + ->columns('*') + ->where(['id = ?' => $id]); + + $row = $db->select($select)->fetch(); + + if ($row === false) { + throw new \Exception('Timeframe not found'); + } + + $timeframe + ->setId($row->id) + ->setName($row->name) + ->setTitle($row->title) + ->setStart($row->start) + ->setEnd($row->end); + + return $timeframe; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + * + * @return $this + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + * + * @return $this + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return string + */ + public function getStart() + { + return $this->start; + } + + /** + * @param string $start + * + * @return $this + */ + public function setStart($start) + { + $this->start = $start; + + return $this; + } + + /** + * @return string + */ + public function getEnd() + { + return $this->end; + } + + /** + * @param string $end + * + * @return $this + */ + public function setEnd($end) + { + $this->end = $end; + + return $this; + } + + public function getTimerange() + { + $start = new \DateTime($this->getStart()); + $end = new \DateTime($this->getEnd()); + + return new Timerange($start, $end); + } +} -- cgit v1.2.3