5 include_once(
'Services/Calendar/classes/class.ilDateTimeException.php');
6 include_once(
'Services/Calendar/classes/class.ilTimeZone.php');
9 define(
'IL_CAL_DATETIME',1);
10 define(
'IL_CAL_DATE',2);
11 define(
'IL_CAL_UNIX',3);
12 define(
'IL_CAL_FKT_DATE',4);
13 define(
'IL_CAL_FKT_GETDATE',5);
14 define(
'IL_CAL_TIMESTAMP',6);
16 define(
'IL_CAL_YEAR',
'year');
17 define(
'IL_CAL_MONTH',
'month');
18 define(
'IL_CAL_WEEK',
'week');
19 define(
'IL_CAL_DAY',
'day');
20 define(
'IL_CAL_HOUR',
'hour');
59 public function __construct($a_date = null,$a_format = 0,$a_tz =
'')
76 $this->
setDate($a_date,$a_format);
81 $this->log->write(__METHOD__.
': '.$exc->getMessage());
93 return $this->unix ?
false :
true;
112 $this->log->write(
'Unsupported timezone given: '.$a_timezone_identifier);
113 throw new ilDateTimeException(
'Unsupported timezone given. Timezone: '.$a_timezone_identifier);
125 return $this->timezone->getIdentifier();
144 switch($a_compare_field)
175 switch($a_compare_field)
207 switch($a_compare_field)
235 $count_str = $a_count > 0 ? (
'+'.$a_count.
' ') : ($a_count.
' ');
237 $this->timezone->switchTZ();
241 $this->unix = strtotime($count_str.
'year',$this->unix);
250 $this->unix = strtotime($count_str.
'month',$this->unix);
264 $this->unix = strtotime($count_str.
'week',$this->unix);
268 $this->unix = strtotime($count_str.
'day',$this->unix);
272 $this->unix = strtotime($count_str.
'hour',$this->unix);
277 $this->unix = strtotime($count_str.
'minute',$this->unix);
284 $this->timezone->restoreTZ();
308 $this->timezone->switchTZ();
310 $offset = mktime(0,0,0,2,1,1970) - gmmktime(0,0,0,2,1,1970);
311 $this->timezone->restoreTZ();
328 $this->unix = $a_date;
333 if(preg_match(
'/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?(Z|[\+\-]\d{2}:?\d{2})?)$/i',$a_date,$d_parts) < 1)
335 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
339 $this->timezone->switchTZ();
340 $this->unix = mktime(
341 isset($d_parts[5]) ? $d_parts[5] : 0,
342 isset($d_parts[6]) ? $d_parts[6] : 0,
343 isset($d_parts[7]) ? $d_parts[7] : 0,
348 if($d_parts[0] ==
'0000-00-00 00:00:00')
353 $this->timezone->restoreTZ();
360 $unix = strtotime($a_date);
364 $this->log->write(__METHOD__.
': Cannot parse date : '.$a_date);
372 if (!isset($a_date[
'seconds']))
374 $a_date[
'seconds'] =
false;
377 $this->timezone->switchTZ();
378 $this->unix = mktime(
385 $this->timezone->restoreTZ();
395 if(preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $a_date,$d_parts) ==
false)
397 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
400 $this->timezone->switchTZ();
401 $this->unix = mktime(
402 isset($d_parts[4]) ? $d_parts[4] : 0,
403 isset($d_parts[5]) ? $d_parts[5] : 0,
404 isset($d_parts[6]) ? $d_parts[6] : 0,
409 if($d_parts[0] ==
'00000000000000' or
410 $d_parts[0] ==
'00000000')
414 $this->timezone->restoreTZ();
428 public function get($a_format,$a_format_str =
'',$a_tz =
'')
438 $this->log->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_tz);
443 #$timezone = $this->timezone;
477 $date[
'isoday'] = $date[
'wday'] == 0 ? 7 : $date[
'wday'];