ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCmiXapiDateTime Class Reference
+ Inheritance diagram for ilCmiXapiDateTime:
+ Collaboration diagram for ilCmiXapiDateTime:

Public Member Functions

 toXapiTimestamp ()
 
- Public Member Functions inherited from ilDateTime
 __construct ($a_date=null, int $a_format=0, string $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 (string $a_timezone_identifier='')
 Switch timezone. More...
 
 getTimeZoneIdentifier ()
 
 increment (string $a_type, int $a_count=1)
 
 getUnixTime ()
 
 setDate ($a_date, int $a_format)
 Set date. More...
 
 get (int $a_format, string $a_format_str='', string $a_tz='')
 get formatted date More...
 
 __toString ()
 to string for date time objects Output is user time zone public More...
 

Static Public Member Functions

static fromXapiTimestamp (string $xapiTimestamp)
 
static fromIliasDateTime (ilDateTime $dateTime)
 
static dateIntervalToISO860Duration (\DateInterval $d)
 
- Static Public Member Functions inherited from ilDateTime
static _before (ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $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, string $a_compare_field='', string $a_tz='')
 Check if two date are equal. More...
 
static _after (ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $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, string $a_compare_field='', string $a_tz='')
 Check whether an date is within a date duration given by start and end. More...
 

Data Fields

const RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v = 'Y-m-d\TH:i:s.uP'
 
- Data Fields inherited from ilDateTime
const YEAR = 'year'
 
const MONTH = 'month'
 
const WEEK = 'week'
 
const DAY = 'day'
 
const HOUR = 'hour'
 
const MINUTE = 'minute'
 
const SECOND = 'second'
 

Additional Inherited Members

- Protected Member Functions inherited from ilDateTime
 parsePartsToDate (int $a_year, int $a_month, int $a_day, ?int $a_hour=null, ?int $a_min=null, ?int $a_sec=null, ?string $a_timezone=null)
 
- Protected Attributes inherited from ilDateTime
ilLogger $log
 
ilTimeZone $timezone = null
 
ilTimeZone $default_timezone = null
 
DateTime $dt_obj = null
 

Detailed Description

Definition at line 30 of file class.ilCmiXapiDateTime.php.

Member Function Documentation

◆ dateIntervalToISO860Duration()

static ilCmiXapiDateTime::dateIntervalToISO860Duration ( \DateInterval  $d)
static

Definition at line 69 of file class.ilCmiXapiDateTime.php.

Referenced by ilCmiXapiLaunchGUI\CMI5preLaunch().

69  : string
70  {
71  $duration = 'P';
72  if (!empty($d->y)) {
73  $duration .= "{$d->y}Y";
74  }
75  if (!empty($d->m)) {
76  $duration .= "{$d->m}M";
77  }
78  if (!empty($d->d)) {
79  $duration .= "{$d->d}D";
80  }
81  if (!empty($d->h) || !empty($d->i) || !empty($d->s)) {
82  $duration .= 'T';
83  if (!empty($d->h)) {
84  $duration .= "{$d->h}H";
85  }
86  if (!empty($d->i)) {
87  $duration .= "{$d->i}M";
88  }
89  if (!empty($d->s)) {
90  $duration .= "{$d->s}S";
91  }
92  // ToDo: nervt!
93  /*
94  if (!empty($d->f)) {
95  if (!empty($d->s)) {
96  $s = $d->s + $d->f;
97  }
98  else {
99  $s = $d->f;
100  }
101  $duration .= "{$s}S";
102  }
103  else
104  {
105  if (!empty($d->s)) {
106  $duration .= "S";
107  }
108  }
109  */
110  }
111  if ($duration === 'P') {
112  $duration = 'PT0S'; // Empty duration (zero seconds)
113  }
114  return $duration;
115  }
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ Here is the caller graph for this function:

◆ fromIliasDateTime()

static ilCmiXapiDateTime::fromIliasDateTime ( ilDateTime  $dateTime)
static
Exceptions
ilDateTimeException

Definition at line 64 of file class.ilCmiXapiDateTime.php.

References ilDateTime\get(), and IL_CAL_UNIX.

Referenced by ilCmiXapiDateDurationInputGUI\getEndXapiDateTime(), and ilCmiXapiDateDurationInputGUI\getStartXapiDateTime().

65  {
66  return new self($dateTime->get(IL_CAL_UNIX), IL_CAL_UNIX);
67  }
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
const IL_CAL_UNIX
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromXapiTimestamp()

static ilCmiXapiDateTime::fromXapiTimestamp ( string  $xapiTimestamp)
static
Exceptions
ilDateTimeException

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

References IL_CAL_UNIX.

Referenced by ilCmiXapiStatementsTableGUI\fillRow(), and ilCmiXapiHighscoreReport\formatRawTimestamp().

50  {
51  $phpDateTime = DateTime::createFromFormat(
52  self::RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v,
53  $xapiTimestamp
54  );
55 
56  $unixTimestamp = $phpDateTime->getTimestamp();
57 
58  return new self($unixTimestamp, IL_CAL_UNIX);
59  }
const IL_CAL_UNIX
+ Here is the caller graph for this function:

◆ toXapiTimestamp()

ilCmiXapiDateTime::toXapiTimestamp ( )

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

References IL_CAL_UNIX.

38  : string
39  {
40  $phpDateTime = new DateTime();
41  $phpDateTime->setTimestamp((int) $this->get(IL_CAL_UNIX));
42 
43  return $phpDateTime->format(self::RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v);
44  }
const IL_CAL_UNIX

Field Documentation

◆ RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v

const ilCmiXapiDateTime::RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v = 'Y-m-d\TH:i:s.uP'

Definition at line 36 of file class.ilCmiXapiDateTime.php.


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