24 include_once(
'Services/Calendar/classes/class.ilDateTimeException.php');
25 include_once(
'Services/Calendar/classes/class.ilTimeZone.php');
28 define(
'IL_CAL_DATETIME',1);
29 define(
'IL_CAL_DATE',2);
30 define(
'IL_CAL_UNIX',3);
31 define(
'IL_CAL_FKT_DATE',4);
32 define(
'IL_CAL_FKT_GETDATE',5);
33 define(
'IL_CAL_TIMESTAMP',6);
35 define(
'IL_CAL_YEAR',
'year');
36 define(
'IL_CAL_MONTH',
'month');
37 define(
'IL_CAL_WEEK',
'week');
38 define(
'IL_CAL_DAY',
'day');
39 define(
'IL_CAL_HOUR',
'hour');
77 public function __construct($a_date = null,$a_format = 0,$a_tz =
'')
94 $this->
setDate($a_date,$a_format);
99 $this->log->write(__METHOD__.
': '.$exc->getMessage());
111 return $this->unix ?
false :
true;
130 $this->log->write(
'Unsupported timezone given: '.$a_timezone_identifier);
131 throw new ilDateTimeException(
'Unsupported timezone given. Timezone: '.$a_timezone_identifier);
143 return $this->timezone->getIdentifier();
162 switch($a_compare_field)
193 switch($a_compare_field)
225 switch($a_compare_field)
253 $count_str = $a_count > 0 ? (
'+'.$a_count.
' ') : ($a_count.
' ');
255 $this->timezone->switchTZ();
259 $this->unix = strtotime($count_str.
'year',$this->unix);
268 $this->unix = strtotime($count_str.
'month',$this->unix);
282 $this->unix = strtotime($count_str.
'week',$this->unix);
286 $this->unix = strtotime($count_str.
'day',$this->unix);
290 $this->unix = strtotime($count_str.
'hour',$this->unix);
294 $this->timezone->restoreTZ();
318 $this->timezone->switchTZ();
320 $offset = mktime(0,0,0,2,1,1970) - gmmktime(0,0,0,2,1,1970);
321 $this->timezone->restoreTZ();
338 $this->unix = $a_date;
343 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) ===
false)
345 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
349 $this->timezone->switchTZ();
350 $this->unix = mktime(
351 isset($d_parts[5]) ? $d_parts[5] : 0,
352 isset($d_parts[6]) ? $d_parts[6] : 0,
353 isset($d_parts[7]) ? $d_parts[7] : 0,
358 if($d_parts[0] ==
'0000-00-00 00:00:00')
363 $this->timezone->restoreTZ();
370 $unix = strtotime($a_date);
374 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
383 $this->timezone->switchTZ();
384 $this->unix = mktime(
391 $this->timezone->restoreTZ();
401 if(preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $a_date,$d_parts) ==
false)
403 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
406 $this->timezone->switchTZ();
407 $this->unix = mktime(
408 isset($d_parts[4]) ? $d_parts[4] : 0,
409 isset($d_parts[5]) ? $d_parts[5] : 0,
410 isset($d_parts[6]) ? $d_parts[6] : 0,
415 if($d_parts[0] ==
'00000000000000' or
416 $d_parts[0] ==
'00000000')
420 $this->timezone->restoreTZ();
434 public function get($a_format,$a_format_str =
'',$a_tz =
'')
444 $this->log->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_tz);
449 #$timezone = $this->timezone;
483 $date[
'isoday'] = $date[
'wday'] == 0 ? 7 : $date[
'wday'];