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)
178 switch($a_compare_field)
213 switch($a_compare_field)
259 $count_str = $a_count > 0 ? (
'+'.$a_count.
' ') : ($a_count.
' ');
261 $this->timezone->switchTZ();
265 $this->unix = strtotime($count_str.
'year',$this->unix);
269 $this->unix = strtotime($count_str.
'month',$this->unix);
273 $this->unix = strtotime($count_str.
'week',$this->unix);
277 $this->unix = strtotime($count_str.
'day',$this->unix);
281 $this->unix = strtotime($count_str.
'hour',$this->unix);
286 $this->unix = strtotime($count_str.
'minute',$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) < 1)
344 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
345 $this->log->logStack();
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);
382 if (!isset($a_date[
'seconds']))
384 $a_date[
'seconds'] =
false;
387 $this->timezone->switchTZ();
388 $this->unix = mktime(
395 $this->timezone->restoreTZ();
405 if(preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $a_date,$d_parts) ==
false)
407 $this->log->write(__METHOD__.
': Cannot parse date: '.$a_date);
410 $this->timezone->switchTZ();
411 $this->unix = mktime(
412 isset($d_parts[4]) ? $d_parts[4] : 0,
413 isset($d_parts[5]) ? $d_parts[5] : 0,
414 isset($d_parts[6]) ? $d_parts[6] : 0,
419 if($d_parts[0] ==
'00000000000000' or
420 $d_parts[0] ==
'00000000')
424 $this->timezone->restoreTZ();
438 public function get($a_format,$a_format_str =
'',$a_tz =
'')
448 $this->log->write(__METHOD__.
': Invalid timezone given. Timezone: '.$a_tz);
453 #$timezone = $this->timezone;
487 $date[
'isoday'] = $date[
'wday'] == 0 ? 7 : $date[
'wday'];