ILIAS  release_7 Revision v7.30-3-g800a261c036
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, $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 fromXapiTimestamp ($xapiTimestamp)
 
static fromIliasDateTime (ilDateTime $dateTime)
 
static dateIntervalToISO860Duration (\DateInterval $d)
 
- Static Public Member Functions inherited from ilDateTime
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 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 ($a_year, $a_month, $a_day, $a_hour=null, $a_min=null, $a_sec=null, $a_timezone=null)
 
- Protected Attributes inherited from ilDateTime
 $log
 
 $timezone = null
 
 $default_timezone = null
 
 $dt_obj
 

Detailed Description

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

Member Function Documentation

◆ dateIntervalToISO860Duration()

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

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

Referenced by ilCmiXapiLaunchGUI\CMI5preLaunch().

63  {
64  $duration = 'P';
65  if (!empty($d->y)) {
66  $duration .= "{$d->y}Y";
67  }
68  if (!empty($d->m)) {
69  $duration .= "{$d->m}M";
70  }
71  if (!empty($d->d)) {
72  $duration .= "{$d->d}D";
73  }
74  if (!empty($d->h) || !empty($d->i) || !empty($d->s)) {
75  $duration .= 'T';
76  if (!empty($d->h)) {
77  $duration .= "{$d->h}H";
78  }
79  if (!empty($d->i)) {
80  $duration .= "{$d->i}M";
81  }
82  if (!empty($d->s)) {
83  $duration .= "{$d->s}S";
84  }
85  // ToDo: nervt!
86  /*
87  if (!empty($d->f)) {
88  if (!empty($d->s)) {
89  $s = $d->s + $d->f;
90  }
91  else {
92  $s = $d->f;
93  }
94  $duration .= "{$s}S";
95  }
96  else
97  {
98  if (!empty($d->s)) {
99  $duration .= "S";
100  }
101  }
102  */
103  }
104  if ($duration === 'P') {
105  $duration = 'PT0S'; // Empty duration (zero seconds)
106  }
107  return $duration;
108  }
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
Parameters
ilDateTime$dateTime
Returns
ilCmiXapiDateTime
Exceptions
ilDateTimeException

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

References ilDateTime\get(), and IL_CAL_UNIX.

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

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

◆ fromXapiTimestamp()

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

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

References IL_CAL_UNIX.

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

41  {
42  $phpDateTime = DateTime::createFromFormat(
43  self::RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v,
44  $xapiTimestamp
45  );
46 
47  $unixTimestamp = $phpDateTime->getTimestamp();
48 
49  return new self($unixTimestamp, IL_CAL_UNIX);
50  }
const IL_CAL_UNIX
+ Here is the caller graph for this function:

◆ toXapiTimestamp()

ilCmiXapiDateTime::toXapiTimestamp ( )
Returns
string
Exceptions
Exception

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

References IL_CAL_UNIX.

28  {
29  $phpDateTime = new DateTime();
30  $phpDateTime->setTimestamp($this->get(IL_CAL_UNIX));
31 
32  return $phpDateTime->format(self::RFC3336_EXTENDED_FIXED_USING_u_INSTEAD_OF_v);
33  }
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 21 of file class.ilCmiXapiDateTime.php.


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