24 include_once(
'Services/Calendar/classes/class.ilDateTimeException.php');
25 include_once(
'Services/Calendar/classes/class.ilTimeZone.php');
36 define(
'IL_CAL_DATETIME',1);
37 define(
'IL_CAL_DATE',2);
38 define(
'IL_CAL_UNIX',3);
39 define(
'IL_CAL_FKT_DATE',4);
40 define(
'IL_CAL_FKT_GETDATE',5);
41 define(
'IL_CAL_TIMESTAMP',6);
43 define(
'IL_CAL_YEAR',
'year');
44 define(
'IL_CAL_MONTH',
'month');
45 define(
'IL_CAL_WEEK',
'week');
46 define(
'IL_CAL_DAY',
'day');
47 define(
'IL_CAL_HOUR',
'hour');
76 public function __construct($a_date = null,$a_format = 0,$a_tz =
'')
93 $this->
setDate($a_date,$a_format);
98 $this->log->write(__METHOD__.
': '.$exc->getMessage());
110 return $this->unix ?
false :
true;
129 $this->log->write(
'Unsupported timezone given: '.$a_timezone_identifier);
130 throw new ilDateTimeException(
'Unsupported timezone given. Timezone: '.$a_timezone_identifier);
142 return $this->timezone->getIdentifier();
161 switch($a_compare_field)
192 switch($a_compare_field)
224 switch($a_compare_field)
252 $count_str = $a_count > 0 ? (
'+'.$a_count.
' ') : ($a_count.
' ');
254 $this->timezone->switchTZ();
258 $this->unix = strtotime($count_str.
'year',$this->unix);
267 $this->unix = strtotime($count_str.
'month',$this->unix);
281 $this->unix = strtotime($count_str.
'week',$this->unix);
285 $this->unix = strtotime($count_str.
'day',$this->unix);
289 $this->unix = strtotime($count_str.
'hour',$this->unix);
293 $this->timezone->restoreTZ();
317 $this->timezone->switchTZ();
319 $offset = mktime(0,0,0,2,1,1970) - gmmktime(0,0,0,2,1,1970);
320 $this->timezone->restoreTZ();
337 $this->unix = $a_date;
342 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)
344 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
348 $this->timezone->switchTZ();
349 $this->unix = mktime(
350 isset($d_parts[5]) ? $d_parts[5] : 0,
351 isset($d_parts[6]) ? $d_parts[6] : 0,
352 isset($d_parts[7]) ? $d_parts[7] : 0,
357 if($d_parts[0] ==
'0000-00-00 00:00:00')
362 $this->timezone->restoreTZ();
369 $unix = strtotime($a_date);
373 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
382 $this->timezone->switchTZ();
383 $this->unix = mktime(
390 $this->timezone->restoreTZ();
400 if(preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $a_date,$d_parts) ==
false)
402 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
405 $this->timezone->switchTZ();
406 $this->unix = mktime(
407 isset($d_parts[4]) ? $d_parts[4] : 0,
408 isset($d_parts[5]) ? $d_parts[5] : 0,
409 isset($d_parts[6]) ? $d_parts[6] : 0,
414 if($d_parts[0] ==
'00000000000000' or
415 $d_parts[0] ==
'00000000')
419 $this->timezone->restoreTZ();
433 public function get($a_format,$a_format_str =
'',$a_tz =
'')
443 $this->log->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_tz);
448 #$timezone = $this->timezone;
482 $date[
'isoday'] = $date[
'wday'] == 0 ? 7 : $date[
'wday'];