Makefile: documentation is deleted on uninstall, some small changes. Documentation...
[iserv-mod-room-reservation.git] / includes / mod_roomReservationTimeslice.inc
1 <?php
2 /**
3 * @file mod_roomReservationTimeslice.inc
4 * Representation of a timeslice
5 * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
6 * @date 03.02.2008
7 *
8 * Copyright © 2007 Roland Hieber
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 * THE SOFTWARE.
27 */
28
29 /** Implementation of a simple timeslice with beginning and ending time */
30 class mod_roomReservationTimeslice {
31
32 /** (timestamp) Time when the timeslice begins */
33 protected $tsBegin = -1;
34 /** (timestamp) Time when the timeslice ends */
35 protected $tsEnd = 86400;
36
37 /***************************************************************************/
38 /**
39 * @name Constructor
40 * @{
41 * Constructor
42 * @param $tsBegin (timestamp) Time when the timeslice begins. Only the
43 * time part is used, the date part is ignored.
44 * @param $tsEnd (timestamp) Time when the timeslice ends. Only the time
45 * part is used, the date part is ignored.
46 * @return mod_roomReservationTimeslice
47 */
48 public function __construct($tsBegin, $tsEnd) {
49 $this->setBegin($tsBegin);
50 $this->setEnd($tsEnd);
51 }
52
53 /***************************************************************************/
54 /**
55 * @}
56 * @name Access to attributes
57 * @{
58 */
59
60 /**
61 * Set the beginning. Only the time part is used, the date part is ignored.
62 * If the timestamp is invalid, an Exception is thrown.
63 * @param $ts (timestamp)
64 * @throws Exception
65 */
66 public function setBegin($ts) {
67 if(intval($ts) >= $this->getEnd()) {
68 throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
69 } else {
70 $this->tsBegin = (intval($ts) % 86400);
71 }
72 }
73
74 /**
75 * Set the ending. Only the time part is used, the date part is ignored.
76 * If the timestamp is invalid, an Exception is thrown.
77 * @param $ts (timestamp)
78 * @throws Exception
79 */
80 public function setEnd($ts) {
81 if($this->getBegin() >= intval($ts)) {
82 throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
83 } else {
84 $this->tsEnd = (intval($ts) % 86400);
85 }
86 }
87
88 /**
89 * Get the beginning.
90 * @return timestamp
91 */
92 public function getBegin() { return $this->tsBegin; }
93
94 /**
95 * Get the ending.
96 * @return timestamp
97 */
98 public function getEnd() { return $this->tsEnd; }
99
100 /** @} */
101 }
102 ?>
This page took 0.055699 seconds and 5 git commands to generate.