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)
250 $count_str = $a_count > 0 ? (
'+'.$a_count.
' ') : ($a_count.
' ');
252 $this->timezone->switchTZ();
256 $this->unix = strtotime($count_str.
'year',$this->unix);
260 $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;
332 $matches = 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);
335 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
336 $this->log->write(__METHOD__.
': '.print_r($matches,
true));
337 $this->log->logStack();
342 if($d_parts[9] ==
'Z')
349 $this->timezone->switchTZ();
351 $this->unix = mktime(
352 isset($d_parts[5]) ? $d_parts[5] : 0,
353 isset($d_parts[6]) ? $d_parts[6] : 0,
354 isset($d_parts[7]) ? $d_parts[7] : 0,
359 if($d_parts[0] ==
'0000-00-00 00:00:00')
364 if($d_parts[9] ==
'Z')
370 $this->timezone->restoreTZ();
378 $unix = strtotime($a_date);
382 $this->log->write(__METHOD__.
': Cannot parse date : '.$a_date);
390 if (!isset($a_date[
'seconds']))
392 $a_date[
'seconds'] =
false;
395 $this->timezone->switchTZ();
396 $this->unix = mktime(
403 $this->timezone->restoreTZ();
413 if(preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $a_date,$d_parts) ==
false)
415 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
418 $this->timezone->switchTZ();
419 $this->unix = mktime(
420 isset($d_parts[4]) ? $d_parts[4] : 0,
421 isset($d_parts[5]) ? $d_parts[5] : 0,
422 isset($d_parts[6]) ? $d_parts[6] : 0,
427 if($d_parts[0] ==
'00000000000000' or
428 $d_parts[0] ==
'00000000')
432 $this->timezone->restoreTZ();
446 public function get($a_format,$a_format_str =
'',$a_tz =
'')
456 $this->log->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_tz);
461 #$timezone = $this->timezone;
495 $date[
'isoday'] = $date[
'wday'] == 0 ? 7 : $date[
'wday'];