+++ /dev/null
-<?php
-/**
- * @file mod_roomReservationTimeslice.inc
- * Representation of a timeslice
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 03.02.2008
- *
- * Copyright © 2007 Roland Hieber
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/** Implementation of a simple timeslice with beginning and ending time */
-class mod_roomReservationTimeslice {
-
- /** (timestamp) Time when the timeslice begins */
- protected $tsBegin = -1;
- /** (timestamp) Time when the timeslice ends */
- protected $tsEnd = 86400;
-
- /***************************************************************************/
- /**
- * @name Constructor
- * @{
- * Constructor
- * @param $tsBegin (timestamp) Time when the timeslice begins. Only the
- * time part is used, the date part is ignored.
- * @param $tsEnd (timestamp) Time when the timeslice ends. Only the time
- * part is used, the date part is ignored.
- * @return mod_roomReservationTimeslice
- */
- public function __construct($tsBegin, $tsEnd) {
- $this->setBegin($tsBegin);
- $this->setEnd($tsEnd);
- }
-
- /***************************************************************************/
- /**
- * @}
- * @name Access to attributes
- * @{
- */
-
- /**
- * Set the beginning. Only the time part is used, the date part is ignored.
- * If the timestamp is invalid, an Exception is thrown.
- * @param $ts (timestamp)
- * @throws Exception
- */
- public function setBegin($ts) {
- if(intval($ts) >= $this->getEnd()) {
- throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
- } else {
- $this->tsBegin = (intval($ts) % 86400);
- }
- }
-
- /**
- * Set the ending. Only the time part is used, the date part is ignored.
- * If the timestamp is invalid, an Exception is thrown.
- * @param $ts (timestamp)
- * @throws Exception
- */
- public function setEnd($ts) {
- if($this->getBegin() >= intval($ts)) {
- throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
- } else {
- $this->tsEnd = (intval($ts) % 86400);
- }
- }
-
- /**
- * Get the beginning.
- * @return timestamp
- */
- public function getBegin() { return $this->tsBegin; }
-
- /**
- * Get the ending.
- * @return timestamp
- */
- public function getEnd() { return $this->tsEnd; }
-
- /** @} */
-}
-?>