ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDateTime Class Reference

@classDescription Date and time handling More...

+ Inheritance diagram for ilDateTime:
+ Collaboration diagram for ilDateTime:

Public Member Functions

 __construct ($a_date=null, $a_format=0, $a_tz='')
 Create new date object. More...
 
 __clone ()
 
 __sleep ()
 
 __wakeup ()
 
 isNull ()
 Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...) More...
 
 switchTimeZone ($a_timezone_identifier='')
 Switch timezone. More...
 
 getTimeZoneIdentifier ()
 get timezone identifier More...
 
 increment ($a_type, $a_count=1)
 increment More...
 
 getUnixTime ()
 get unix time More...
 
 getUTCOffset ()
 get UTC offset More...
 
 setDate ($a_date, $a_format)
 Set date. More...
 
 get ($a_format, $a_format_str='', $a_tz='')
 get formatted date More...
 
 __toString ()
 to string for date time objects Output is user time zone More...
 

Static Public Member Functions

static _before (ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
 compare two dates and check start is before end This method does not consider tz offsets. More...
 
static _equals (ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
 Check if two date are equal. More...
 
static _after (ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
 compare two dates and check start is after end This method does not consider tz offsets. More...
 
static _within (ilDateTime $dt, ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
 Check whether an date is within a date duration given by start and end. More...
 

Data Fields

const YEAR = 'year'
 
const MONTH = 'month'
 
const WEEK = 'week'
 
const DAY = 'day'
 
const HOUR = 'hour'
 
const MINUTE = 'minute'
 

Protected Member Functions

 parsePartsToDate ($a_year, $a_month, $a_day, $a_hour=null, $a_min=null, $a_sec=null, $a_timezone=null)
 

Protected Attributes

 $log
 
 $timezone = null
 
 $default_timezone = null
 
 $dt_obj
 

Detailed Description

@classDescription Date and time handling

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 32 of file class.ilDateTime.php.

Constructor & Destructor Documentation

◆ __construct()

ilDateTime::__construct (   $a_date = null,
  $a_format = 0,
  $a_tz = '' 
)

Create new date object.

@access public

Parameters
mixedinteger string following the format given as the second parameter
intformat of date presentation

throws ilDateTimeException

Definition at line 63 of file class.ilDateTime.php.

64 {
65 global $ilLog;
66
67 $this->log = $ilLog;
68
69 try {
70 $this->timezone = ilTimeZone::_getInstance($a_tz);
71 $this->default_timezone = ilTimeZone::_getInstance('');
72
73 $this->setDate($a_date, $a_format);
74 } catch (ilTimeZoneException $exc) {
75 $this->log->write(__METHOD__ . ': ' . $exc->getMessage());
76 throw new ilDateTimeException('Unsupported timezone given. Timezone: ' . $a_tz);
77 }
78 }
Class for DateTime exceptions.
setDate($a_date, $a_format)
Set date.
Class for TimeZone exceptions.
static _getInstance($a_tz='')
get instance by timezone

References $ilLog, ilTimeZone\_getInstance(), and setDate().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDateTime::__clone ( )

Definition at line 80 of file class.ilDateTime.php.

81 {
82 if ($this->dt_obj) {
83 $this->dt_obj = clone $this->dt_obj;
84 }
85 }

References $dt_obj.

◆ __sleep()

ilDateTime::__sleep ( )

Definition at line 87 of file class.ilDateTime.php.

88 {
89 return array('timezone', 'default_timezone', 'dt_obj');
90 }

◆ __toString()

ilDateTime::__toString ( )

to string for date time objects Output is user time zone

@access public

Parameters

return

Reimplemented in ilDate.

Definition at line 569 of file class.ilDateTime.php.

570 {
571 return $this->get(IL_CAL_DATETIME) . '<br>';
572 }
const IL_CAL_DATETIME

References IL_CAL_DATETIME.

◆ __wakeup()

ilDateTime::__wakeup ( )

Definition at line 92 of file class.ilDateTime.php.

93 {
94 global $ilLog;
95
96 $this->log = $ilLog;
97 }

References $ilLog.

◆ _after()

static ilDateTime::_after ( ilDateTime  $start,
ilDateTime  $end,
  $a_compare_field = '',
  $a_tz = '' 
)
static

compare two dates and check start is after end This method does not consider tz offsets.

So you have to take care that both dates are defined in the the same timezone

@access public

Parameters
objectilDateTime
objectilDateTime
stringfield used for comparison. E.g IL_CAL_YEAR checks if start is one or more years after than end
stringtimezone

Definition at line 222 of file class.ilDateTime.php.

223 {
224 if ($start->isNull() || $end->isNull()) {
225 return false;
226 }
227
228 switch ($a_compare_field) {
229 case IL_CAL_YEAR:
230 return $start->get(IL_CAL_FKT_DATE, 'Y', $a_tz) > $end->get(IL_CAL_FKT_DATE, 'Y', $a_tz);
231
232 case IL_CAL_MONTH:
233 return (int) $start->get(IL_CAL_FKT_DATE, 'Ym', $a_tz) > $end->get(IL_CAL_FKT_DATE, 'Ym', $a_tz);
234
235 case IL_CAL_DAY:
236 return (int) $start->get(IL_CAL_FKT_DATE, 'Ymd', $a_tz) > $end->get(IL_CAL_FKT_DATE, 'Ymd', $a_tz);
237
238 case '':
239 default:
240 return $start->dt_obj > $end->dt_obj;
241
242 }
243 }
const IL_CAL_YEAR
const IL_CAL_MONTH
const IL_CAL_FKT_DATE
const IL_CAL_DAY
get($a_format, $a_format_str='', $a_tz='')
get formatted date
isNull()
Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)
$end
Definition: saml1-acs.php:18

References $end, get(), IL_CAL_DAY, IL_CAL_FKT_DATE, IL_CAL_MONTH, IL_CAL_YEAR, and isNull().

Referenced by ilObjGroupAccess\_registrationEnabled(), _within(), ilCalendarRecurrenceCalculator\applyDurationPeriod(), ilCalendarRecurrenceCalculator\applyLimits(), ilCalendarRecurrenceCalculator\calculateDateList(), ilDateDurationInputGUI\checkInput(), ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), ilCourseRegistrationGUI\fillRegistrationPeriod(), ilGroupRegistrationGUI\fillRegistrationPeriod(), ilConsultationHourBookingTableGUI\fillRow(), ilPageObject\getActive(), ilCalendarAppointmentPanelGUI\getHTML(), ilCalendarAgendaListGUI\getHTML(), ilObjCourse\getSubItems(), ilBookingEntry\isAppointmentBookableForUser(), ilECSCategoryMappingRule\matchesValue(), ilObjGroup\register(), and ilECSCategoryMappingRule\validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _before()

static ilDateTime::_before ( ilDateTime  $start,
ilDateTime  $end,
  $a_compare_field = '',
  $a_tz = '' 
)
static

compare two dates and check start is before end This method does not consider tz offsets.

So you have to take care that both dates are defined in the the same timezone

@access public

Parameters
objectilDateTime
objectilDateTime
stringfield used for comparison. E.g IL_CAL_YEAR checks if start is one or more years earlier than end
stringtimezone
Returns
bool

Definition at line 152 of file class.ilDateTime.php.

153 {
154 if ($start->isNull() || $end->isNull()) {
155 return false;
156 }
157
158 switch ($a_compare_field) {
159 case IL_CAL_YEAR:
160 return $start->get(IL_CAL_FKT_DATE, 'Y', $a_tz) < $end->get(IL_CAL_FKT_DATE, 'Y', $a_tz);
161
162 case IL_CAL_MONTH:
163 return (int) $start->get(IL_CAL_FKT_DATE, 'Ym', $a_tz) < $end->get(IL_CAL_FKT_DATE, 'Ym', $a_tz);
164
165 case IL_CAL_DAY:
166 return (int) $start->get(IL_CAL_FKT_DATE, 'Ymd', $a_tz) < $end->get(IL_CAL_FKT_DATE, 'Ymd', $a_tz);
167
168 case '':
169 default:
170 return $start->dt_obj < $end->dt_obj;
171
172 }
173 }

References $end, get(), IL_CAL_DAY, IL_CAL_FKT_DATE, IL_CAL_MONTH, IL_CAL_YEAR, and isNull().

Referenced by ilObjGroupAccess\_registrationEnabled(), _within(), ilCalendarBlockGUI\addMiniMonth(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarRecurrenceCalculator\applyDurationPeriod(), ilCalendarRecurrenceCalculator\applyLimits(), ilCalendarRecurrenceCalculator\calculateDateList(), ilBookingEntry\cancelBooking(), ilCourseRegistrationGUI\fillRegistrationPeriod(), ilGroupRegistrationGUI\fillRegistrationPeriod(), ilECSServerTableGUI\fillRow(), ilPageObject\getActive(), ilCalendarAgendaListGUI\getHTML(), ilCalendarBlockGUI\getHTML(), ilObjCourse\getSubItems(), ilExerciseManagementGUI\handleIndividualDeadlineCallsObject(), ilECSTimePlace\loadFromJson(), ilObjCourseAccess\lookupRegistrationInfo(), ilObjGroupAccess\lookupRegistrationInfo(), ilECSCategoryMappingRule\matchesValue(), ilCalendarRecurrenceCalculator\optimizeStartingTime(), ilUserQuery\query(), ilObjGroup\register(), ilStudyProgramme\setLastChange(), ilStudyProgrammeAssignment\setLastChange(), ilStudyProgrammeProgress\setLastChange(), ilCalendarPresentationGUI\synchroniseExternalCalendars(), and ilCalendarEntry\validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _equals()

static ilDateTime::_equals ( ilDateTime  $start,
ilDateTime  $end,
  $a_compare_field = '',
  $a_tz = '' 
)
static

Check if two date are equal.

@access public

Parameters
objectilDateTime
objectilDateTime
stringfield used for comparison. E.g IL_CAL_YEAR checks if start is the same years than end
stringtimzone
Returns
bool

Definition at line 187 of file class.ilDateTime.php.

188 {
189 if ($start->isNull() || $end->isNull()) {
190 return false;
191 }
192
193 switch ($a_compare_field) {
194 case IL_CAL_YEAR:
195 return $start->get(IL_CAL_FKT_DATE, 'Y', $a_tz) == $end->get(IL_CAL_FKT_DATE, 'Y', $a_tz);
196
197 case IL_CAL_MONTH:
198 return (int) $start->get(IL_CAL_FKT_DATE, 'Ym', $a_tz) == $end->get(IL_CAL_FKT_DATE, 'Ym', $a_tz);
199
200 case IL_CAL_DAY:
201 return (int) $start->get(IL_CAL_FKT_DATE, 'Ymd', $a_tz) == $end->get(IL_CAL_FKT_DATE, 'Ymd', $a_tz);
202
203 case '':
204 default:
205 return $start->dt_obj == $end->dt_obj;
206
207 }
208 }

References $end, get(), IL_CAL_DAY, IL_CAL_FKT_DATE, IL_CAL_MONTH, IL_CAL_YEAR, and isNull().

Referenced by ilCalendarUtil\_isToday(), _within(), ilCalendarBlockGUI\addMiniMonth(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarRecurrenceCalculator\calculateDateList(), ilCalendarAppointmentGUI\edit(), ilSubItemSelectionTableGUI\fillRow(), ilDatePresentation\formatPeriod(), ilCalendarAgendaListGUI\getHTML(), ilDatePresentation\isToday(), ilDatePresentation\isTomorrow(), ilDatePresentation\isYesterday(), and ilDateList\removeByDAY().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _within()

static ilDateTime::_within ( ilDateTime  $dt,
ilDateTime  $start,
ilDateTime  $end,
  $a_compare_field = '',
  $a_tz = '' 
)
static

Check whether an date is within a date duration given by start and end.

Parameters
ilDateTime$dt
ilDateTime$start
ilDateTime$end
type$a_compare_field
type$a_tz

Definition at line 253 of file class.ilDateTime.php.

254 {
255 return
256 (ilDateTime::_after($dt, $start, $a_compare_field, $a_tz) or ilDateTime::_equals($dt, $start, $a_compare_field, $a_tz)) &&
257 (ilDateTime::_before($dt, $end, $a_compare_field, $a_tz) or ilDateTime::_equals($dt, $end, $a_compare_field, $a_tz));
258 }
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.

References $end, _after(), _before(), and _equals().

Referenced by ilCalendarScheduleFilterExercise\addCustomEvents(), ilCalendarHeaderNavigationGUI\getHTML(), and ilObjCourse\getSubItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

ilDateTime::get (   $a_format,
  $a_format_str = '',
  $a_tz = '' 
)

get formatted date

@access public

Parameters
intformat type
stringformat string
stringa specific timezone

Reimplemented in ilDate.

Definition at line 496 of file class.ilDateTime.php.

497 {
498 if ($this->isNull()) {
499 return;
500 }
501
502 if ($a_tz) {
503 try {
505 } catch (ilTimeZoneException $exc) {
506 $this->log->write(__METHOD__ . ': Invalid timezone given. Timezone: ' . $a_tz);
507 }
508 } else {
510 }
511
512 $out_date = clone($this->dt_obj);
513 $out_date->setTimezone(new DateTimeZone($timezone->getIdentifier()));
514
515 switch ($a_format) {
516 case IL_CAL_UNIX:
517 // timezone unrelated
518 $date = $this->getUnixTime();
519 break;
520
521 case IL_CAL_DATE:
522 $date = $out_date->format('Y-m-d');
523 break;
524
525 case IL_CAL_DATETIME:
526 $date = $out_date->format('Y-m-d H:i:s');
527 break;
528
529 case IL_CAL_FKT_DATE:
530 $date = $out_date->format($a_format_str);
531 break;
532
534 $date = array(
535 'seconds' => (int) $out_date->format('s')
536 ,'minutes' => (int) $out_date->format('i')
537 ,'hours' => (int) $out_date->format('G')
538 ,'mday' => (int) $out_date->format('j')
539 ,'wday' => (int) $out_date->format('w')
540 ,'mon' => (int) $out_date->format('n')
541 ,'year' => (int) $out_date->format('Y')
542 ,'yday' => (int) $out_date->format('z')
543 ,'weekday' => $out_date->format('l')
544 ,'month' => $out_date->format('F')
545 ,'isoday' => (int) $out_date->format('N')
546 );
547 break;
548
549 case IL_CAL_ISO_8601:
550 $date = $out_date->format('c');
551 break;
552
553 case IL_CAL_TIMESTAMP:
554 $date = $out_date->format('YmdHis');
555 break;
556 }
557
558 return $date;
559 }
const IL_CAL_FKT_GETDATE
const IL_CAL_DATE
const IL_CAL_ISO_8601
const IL_CAL_TIMESTAMP
const IL_CAL_UNIX
getUnixTime()
get unix time

References $default_timezone, $timezone, ilTimeZone\_getInstance(), getUnixTime(), IL_CAL_DATE, IL_CAL_DATETIME, IL_CAL_FKT_DATE, IL_CAL_FKT_GETDATE, IL_CAL_ISO_8601, IL_CAL_TIMESTAMP, IL_CAL_UNIX, and isNull().

Referenced by _after(), _before(), _equals(), ilConsultationHourUtils\findCalendarAppointmentsForBooking(), ilDatePresentation\formatDate(), ilDatePresentation\formatPeriod(), ilCalendarRecurrenceCalculator\getYearWeekDays(), ilCalendarRegistration\isRegistered(), ilLTIDataConnector\lookupResourcesForAllUsersSinceDate(), ilUtil\period2String(), ilExcel\prepareDateValue(), ilExAssignment\setIndividualDeadline(), ilStudyProgramme\setLastChange(), ilStudyProgrammeAssignment\setLastChange(), ilStudyProgrammeProgress\setLastChange(), and ilCalendarRegistration\unregister().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimeZoneIdentifier()

ilDateTime::getTimeZoneIdentifier ( )

get timezone identifier

@access public

Definition at line 133 of file class.ilDateTime.php.

134 {
135 return $this->timezone->getIdentifier();
136 }

Referenced by parsePartsToDate(), and setDate().

+ Here is the caller graph for this function:

◆ getUnixTime()

ilDateTime::getUnixTime ( )

get unix time

@access public

Definition at line 320 of file class.ilDateTime.php.

321 {
322 if (!$this->isNull()) {
323 return $this->dt_obj->getTimestamp();
324 }
325 }

References isNull().

Referenced by get(), and increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUTCOffset()

ilDateTime::getUTCOffset ( )

get UTC offset

@access public

Returns
offset to utc in seconds

Definition at line 333 of file class.ilDateTime.php.

334 {
335 if (!$this->isNull()) {
336 // already correct/current timezone?
337 $offset = $this->dt_obj->getOffset();
338
339 // TODO: This is wrong: calculate UTC offset of given date
340 // $offset = mktime(0,0,0,2,1,1970) - gmmktime(0,0,0,2,1,1970);
341 }
342 return $offset;
343 }

References isNull().

+ Here is the call graph for this function:

◆ increment()

ilDateTime::increment (   $a_type,
  $a_count = 1 
)

increment

@access public

Parameters
inttype
intcount

Definition at line 268 of file class.ilDateTime.php.

269 {
270 if ($this->isNull()) {
271 return;
272 }
273
274 $sub = ($a_count < 0);
275 $count_str = abs($a_count);
276
277 switch ($a_type) {
278 case self::YEAR:
279 $count_str .= 'year';
280 break;
281
282 case self::MONTH:
283 $count_str .= 'month';
284 break;
285
286 case self::WEEK:
287 $count_str .= 'week';
288 break;
289
290 case self::DAY:
291 $count_str .= 'day';
292 break;
293
294 case self::HOUR:
295 $count_str .= 'hour';
296 break;
297
298 case self::MINUTE:
299 $count_str .= 'minute';
300 break;
301 }
302
303 $interval = date_interval_create_from_date_string($count_str);
304 if (!$sub) {
305 $this->dt_obj->add($interval);
306 } else {
307 $this->dt_obj->sub($interval);
308 }
309
310 // ???
311 return $this->getUnixTime();
312 }
$a_type
Definition: workflow.php:92

References $a_type, DAY, getUnixTime(), HOUR, isNull(), MINUTE, MONTH, WEEK, and YEAR.

Referenced by ilCalendarSchedule\initPeriod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNull()

ilDateTime::isNull ( )

Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)

Returns
bool

Definition at line 104 of file class.ilDateTime.php.

105 {
106 return !($this->dt_obj instanceof DateTime);
107 }

Referenced by _after(), _before(), _equals(), ilDatePresentation\formatDate(), get(), getUnixTime(), getUTCOffset(), and increment().

+ Here is the caller graph for this function:

◆ parsePartsToDate()

ilDateTime::parsePartsToDate (   $a_year,
  $a_month,
  $a_day,
  $a_hour = null,
  $a_min = null,
  $a_sec = null,
  $a_timezone = null 
)
protected

Definition at line 345 of file class.ilDateTime.php.

346 {
347 $a_year = (int) $a_year;
348 $a_month = (int) $a_month;
349 $a_day = (int) $a_day;
350
351 if (!$a_year) {
352 return;
353 }
354
355 try {
356 $a_hour = (int) $a_hour;
357 $a_min = (int) $a_min;
358 $a_sec = (int) $a_sec;
359
360 $format = $a_year . '-' . $a_month . '-' . $a_day;
361
362 if ($a_hour !== null) {
363 $format .= ' ' . (int) $a_hour . ':' . (int) $a_min . ':' . (int) $a_sec;
364
365 // use current timezone if no other given
366 if (!$a_timezone) {
367 $a_timezone = $this->getTimeZoneIdentifier();
368 }
369
370 $date = new DateTime($format, new DateTimeZone($a_timezone));
371 } else {
372 $date = new DateTime($format);
373 }
374 } catch (Exception $ex) {
375 // :TODO: do anything?
376 }
377 return ($date instanceof DateTime)
378 ? $date
379 : null;
380 }
getTimeZoneIdentifier()
get timezone identifier
$format
Definition: metadata.php:141

References $format, and getTimeZoneIdentifier().

Referenced by setDate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDate()

ilDateTime::setDate (   $a_date,
  $a_format 
)

Set date.

@access public

Parameters
mixeddate
intformat
Exceptions
ilDateTimeException

Definition at line 392 of file class.ilDateTime.php.

393 {
394 $this->dt_obj = null;
395
396 if (!$a_date) {
397 return;
398 }
399
400 switch ($a_format) {
401 case IL_CAL_UNIX:
402 try {
403 $this->dt_obj = new DateTime('@' . $a_date);
404 $this->dt_obj->setTimezone(new DateTimeZone($this->getTimeZoneIdentifier()));
405 } catch (Exception $ex) {
406 $message = 'Cannot parse date: ' . $a_date . ' with format ' . $a_format;
407 $this->log->write($message);
408 throw new ilDateTimeException($message);
409 }
410 break;
411
412 case IL_CAL_DATETIME:
413 $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);
414 if ($matches < 1) {
415 $this->log->write(__METHOD__ . ': Cannot parse date: ' . $a_date);
416 $this->log->write(__METHOD__ . ': ' . print_r($matches, true));
417 $this->log->logStack();
418 throw new ilDateTimeException('Cannot parse date: ' . $a_date);
419 }
420
421 $tz_id = ($d_parts[9] == 'Z')
422 ? 'UTC'
423 : $this->getTimeZoneIdentifier();
424 $this->dt_obj = $this->parsePartsToDate(
425 $d_parts[1],
426 $d_parts[2],
427 $d_parts[3],
428 $d_parts[5],
429 $d_parts[6],
430 $d_parts[7],
431 $tz_id
432 );
433 break;
434
435 case IL_CAL_DATE:
436 try {
437 // Pure dates are not timezone sensible.
438 $this->dt_obj = new DateTime($a_date, new DateTimeZone('UTC'));
439 } catch (Exception $ex) {
440 $this->log->write(__METHOD__ . ': Cannot parse date: ' . $a_date);
441 throw new ilDateTimeException('Cannot parse date: ' . $a_date);
442 }
443 break;
444
446 // Format like getdate parameters
447 $this->dt_obj = $this->parsePartsToDate(
448 $a_date['year'],
449 $a_date['mon'],
450 $a_date['mday'],
451 $a_date['hours'],
452 $a_date['minutes'],
453 $a_date['seconds'],
454 $this->getTimeZoneIdentifier()
455 );
456 break;
457
458 case IL_CAL_TIMESTAMP:
459 if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $a_date, $d_parts) == false) {
460 $this->log->write(__METHOD__ . ': Cannot parse date: ' . $a_date);
461 throw new ilDateTimeException('Cannot parse date: ' . $a_date);
462 }
463 $this->dt_obj = $this->parsePartsToDate(
464 $d_parts[1],
465 $d_parts[2],
466 $d_parts[3],
467 $d_parts[4],
468 $d_parts[5],
469 $d_parts[6],
470 $this->getTimeZoneIdentifier()
471 );
472 break;
473
474 case IL_CAL_ISO_8601:
475 $this->dt_obj = DateTime::createFromFormat(
476 DateTime::ISO8601,
477 $a_date,
478 new DateTimeZone($this->getTimeZoneIdentifier())
479 );
480 break;
481 }
482
483 // remove set timezone since it does not influence the internal date.
484 // the tz must be passed in the moment of the creation of the date object.
485 return true;
486 }
parsePartsToDate($a_year, $a_month, $a_day, $a_hour=null, $a_min=null, $a_sec=null, $a_timezone=null)
catch(Exception $e) $message

References $message, getTimeZoneIdentifier(), IL_CAL_DATE, IL_CAL_DATETIME, IL_CAL_FKT_GETDATE, IL_CAL_ISO_8601, IL_CAL_TIMESTAMP, IL_CAL_UNIX, and parsePartsToDate().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ switchTimeZone()

ilDateTime::switchTimeZone (   $a_timezone_identifier = '')

Switch timezone.

@access public

Parameters
stringPHP timezone identifier
Exceptions
ilDateTimeException

Definition at line 116 of file class.ilDateTime.php.

117 {
118 try {
119 $this->timezone = ilTimeZone::_getInstance($a_timezone_identifier);
120 return true;
121 } catch (ilTimeZoneException $e) {
122 $this->log->write('Unsupported timezone given: ' . $a_timezone_identifier);
123 throw new ilDateTimeException('Unsupported timezone given. Timezone: ' . $a_timezone_identifier);
124 }
125 }

References ilTimeZone\_getInstance().

Referenced by ilCalendarRecurrenceCalculator\adjustTimeZones().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $default_timezone

ilDateTime::$default_timezone = null
protected

Definition at line 44 of file class.ilDateTime.php.

Referenced by get().

◆ $dt_obj

ilDateTime::$dt_obj
protected

Definition at line 49 of file class.ilDateTime.php.

Referenced by __clone().

◆ $log

ilDateTime::$log
protected

Definition at line 41 of file class.ilDateTime.php.

◆ $timezone

ilDateTime::$timezone = null
protected

Definition at line 43 of file class.ilDateTime.php.

Referenced by get().

◆ DAY

◆ HOUR

const ilDateTime::HOUR = 'hour'

Definition at line 38 of file class.ilDateTime.php.

Referenced by ilConsultationHoursGUI\createAppointments(), and increment().

◆ MINUTE

const ilDateTime::MINUTE = 'minute'

◆ MONTH

◆ WEEK

◆ YEAR


The documentation for this class was generated from the following file: