ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSTimePlace.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23  */
24 
35 {
36  public $room = '';
37  public $begin = '';
38  public $end = '';
39  public $cycle = '';
40 
48  public function __construct()
49  {
50  }
51 
59  public function loadFromJson($a_json)
60  {
61  global $ilLog;
62 
63  if (!is_object($a_json)) {
64  $ilLog->write(__METHOD__ . ': Cannot load from JSON. No object given.');
65  throw new ilException('Cannot parse ECSContent.');
66  }
67 
68  $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($a_json, true));
69 
70  $this->room = $a_json->room;
71  $this->begin = $a_json->begin;
72  $this->end = $a_json->end;
73  $this->cycle = $a_json->cycle;
74  #$this->day = $a_json->day;
75 
76  $two = new ilDate('2000-01-02', IL_CAL_DATE);
77  if (ilDate::_before(new ilDateTime($this->getUTBegin(), IL_CAL_UNIX), $two)) {
78  $this->begin = '';
79  }
80  if (ilDate::_before(new ilDateTime($this->getUTEnd(), IL_CAL_UNIX), $two)) {
81  $this->end = '';
82  }
83  }
84 
91  public function setBegin($a_begin)
92  {
93  // is it unix time ?
94  if (is_numeric($a_begin) and $a_begin) {
95  $dt = new ilDateTime($a_begin, IL_CAL_UNIX, ilTimeZone::UTC);
96  $this->end = $dt->get(IL_CAL_DATE);
97  } else {
98  $this->begin = $a_begin;
99  }
100  }
101 
107  public function getBegin()
108  {
109  return $this->begin;
110  }
111 
118  public function getUTBegin()
119  {
120  include_once './Services/Calendar/classes/class.ilDateTime.php';
121  $dt = new ilDateTime($this->begin, IL_CAL_DATE, ilTimeZone::UTC);
122  return $dt->get(IL_CAL_UNIX);
123  }
124 
132  public function setEnd($a_end)
133  {
134  // is it unix time ?
135  if (is_numeric($a_end) and $a_end) {
136  $dt = new ilDateTime($a_end, IL_CAL_UNIX, ilTimeZone::UTC);
137  $this->end = $dt->get(IL_CAL_DATE);
138  } else {
139  $this->end = $a_end;
140  }
141  }
142 
148  public function getEnd()
149  {
150  return $this->end;
151  }
152 
159  public function getUTEnd()
160  {
161  include_once './Services/Calendar/classes/class.ilDateTime.php';
162  $dt = new ilDateTime($this->end, IL_CAL_DATE, ilTimeZone::UTC);
163  return $dt->get(IL_CAL_UNIX);
164  }
165 
173  public function setRoom($a_room)
174  {
175  $this->room = $a_room;
176  }
177 
184  public function getRoom()
185  {
186  return $this->room;
187  }
188 
196  public function setCycle($a_cycle)
197  {
198  $this->cycle = $a_cycle;
199  }
200 
208  public function getCycle()
209  {
210  return $this->cycle;
211  }
212 }
setRoom($a_room)
set room
Representation of ECS EContent Time Place.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setCycle($a_cycle)
set cycle
const IL_CAL_UNIX
Class for single dates.
Date and time handling
loadFromJson($a_json)
load from json
getUTBegin()
get begin as unix time
setBegin($a_begin)
set begin
__construct()
Constructor.
const IL_CAL_DATE
setEnd($a_end)
set end
getUTEnd()
get end as unix time