ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBMFType_dateTime Class Reference
+ Collaboration diagram for ilBMFType_dateTime:

Public Member Functions

 ilBMFType_dateTime ($date=-1)
 Constructor.
 toSOAP ($date=NULL)
 Alias of ilBMFType_dateTime::toUTC.
 toString ($timestamp=0)
 Converts this object or a timestamp to an ISO 8601 date/time string.
 _split ($datestr)
 Splits a date/time into its components.
 toUTC ($datestr=null)
 Returns an ISO 8601 formatted UTC date/time string.
 toUnixtime ($datestr=null)
 Returns a unix timestamp.
 compare ($date1, $date2=null)
 Compares two dates or this object with a second date.

Data Fields

 $ereg_iso8601 = '(-?[0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]*)?(Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?'
 $timestamp = -1

Detailed Description

Definition at line 33 of file class.ilBMFType_dateTime.php.

Member Function Documentation

ilBMFType_dateTime::_split (   $datestr)

Splits a date/time into its components.

Parameters
string | integer$datestrA unix timestamp or ISO 8601 date/time string. If empty, this object is used.
Returns
boolean|array An array with the date and time components or false on failure.

Definition at line 166 of file class.ilBMFType_dateTime.php.

References toString().

Referenced by toUnixtime(), and toUTC().

{
if (!$datestr)
$datestr = $this->toString();
else if (gettype($datestr) == 'integer')
$datestr = $this->toString($datestr);
if (ereg($this->ereg_iso8601,$datestr,$regs)) {
if ($regs[8] != '' && $regs[8] != 'Z') {
$op = substr($regs[8],0,1);
$h = substr($regs[8],1,2);
if (strstr($regs[8],':')) {
$m = substr($regs[8],4,2);
} else {
$m = substr($regs[8],3,2);
}
if ($op == '+') {
$regs[4] = $regs[4] - $h;
if ($regs[4] < 0) $regs[4] += 24;
$regs[5] = $regs[5] - $m;
if ($regs[5] < 0) $regs[5] += 60;
} else {
$regs[4] = $regs[4] + $h;
if ($regs[4] > 23) $regs[4] -= 24;
$regs[5] = $regs[5] + $m;
if ($regs[5] > 59) $regs[5] -= 60;
}
}
return $regs;
}
return FALSE;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFType_dateTime::compare (   $date1,
  $date2 = null 
)

Compares two dates or this object with a second date.

Parameters
string | integer$date1A unix timestamp or ISO 8601 date/time string.
string | integer$date2A unix timestamp or ISO 8601 date/time string. If empty, this object is used.
Returns
integer The difference between the first and the second date.

Definition at line 257 of file class.ilBMFType_dateTime.php.

References $timestamp, and toUnixtime().

{
if (is_null($date2)) {
$date2 = $date1;
$date1 = $this->timestamp;
}
if (!is_int($date1)) {
$date1 = $this->toUnixtime($date1);
}
if (!is_int($date2)) {
$date2 = $this->toUnixtime($date2);
}
if ($date1 != -1 && $date2 != -1) {
return $date1 - $date2;
}
return -1;
}

+ Here is the call graph for this function:

ilBMFType_dateTime::ilBMFType_dateTime (   $date = -1)

Constructor.

Parameters
string | integer$dateThe timestamp or ISO 8601 formatted date and time this object is going to represent.

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

References toUnixtime().

{
if ($date == -1) {
$this->timestamp = time();
} elseif (is_int($date)) {
$this->timestamp = $date;
} else {
$this->timestamp = $this->toUnixtime($date);
}
}

+ Here is the call graph for this function:

ilBMFType_dateTime::toSOAP (   $date = NULL)

Alias of ilBMFType_dateTime::toUTC.

Definition at line 78 of file class.ilBMFType_dateTime.php.

References toUTC().

{
return $this->toUTC($date);
}

+ Here is the call graph for this function:

ilBMFType_dateTime::toString (   $timestamp = 0)

Converts this object or a timestamp to an ISO 8601 date/time string.

Parameters
integer$timestampA unix timestamp
Returns
string An ISO 8601 formatted date/time string.

Definition at line 90 of file class.ilBMFType_dateTime.php.

References $timestamp.

Referenced by _split().

{
if (!$timestamp) {
}
if ($timestamp < 0) {
return 0;
}
return date('Y-m-d\TH:i:sO', $timestamp);
}

+ Here is the caller graph for this function:

ilBMFType_dateTime::toUnixtime (   $datestr = null)

Returns a unix timestamp.

Parameters
string | integer$datestr
See Also
ilBMFType_dateTime::_split
Returns
integer The unix timestamp.

Definition at line 230 of file class.ilBMFType_dateTime.php.

References _split().

Referenced by compare(), and ilBMFType_dateTime().

{
$regs = $this->_split($datestr);
if ($regs) {
/* Databay: Changes for BMF */
/* return strtotime(sprintf('%04d-%02d-%02d %02d:%02d:%02dZ',
$regs[1],
$regs[2],
$regs[3],
$regs[4],
$regs[5],
$regs[6]));*/
return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
}
return -1;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFType_dateTime::toUTC (   $datestr = null)

Returns an ISO 8601 formatted UTC date/time string.

Parameters
string | integer$datestr
See Also
ilBMFType_dateTime::_split
Returns
string The ISO 8601 formatted UTC date/time string.

Definition at line 206 of file class.ilBMFType_dateTime.php.

References _split().

Referenced by toSOAP().

{
$regs = $this->_split($datestr);
if ($regs) {
return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',
$regs[1],
$regs[2],
$regs[3],
$regs[4],
$regs[5],
$regs[6]);
}
return '';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilBMFType_dateTime::$ereg_iso8601 = '(-?[0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]*)?(Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?'

Definition at line 53 of file class.ilBMFType_dateTime.php.

ilBMFType_dateTime::$timestamp = -1

Definition at line 55 of file class.ilBMFType_dateTime.php.

Referenced by compare(), and toString().


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