Public Member Functions | |
ilBMFType_dateTime ($date=-1) | |
toSOAP ($date=NULL) | |
toString ($timestamp=0) | |
_split ($datestr) | |
toUTC ($datestr=NULL) | |
toUnixtime ($datestr=NULL) | |
compare ($date1, $date2=NULL) | |
_test ($orig= '2001-04-25T09:31:41-0700') | |
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 |
Definition at line 22 of file class.ilBMFType_dateTime.php.
ilBMFType_dateTime::_split | ( | $ | datestr | ) |
Definition at line 60 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; }
ilBMFType_dateTime::_test | ( | $ | orig = '2001-04-25T09:31:41-0700' |
) |
Definition at line 127 of file class.ilBMFType_dateTime.php.
References $b1, toString(), toUnixtime(), and toUTC().
:31:41-0700') { $utc = $this->toUTC($orig); $ts1 = $this->toUnixtime($orig); $ts2 = $this->toUnixtime($utc); $b1 = $this->toString($ts1); $b2 = $this->toString($ts2); print "orig: $orig\n"; print "orig toUTC: $utc\n"; print "orig ts: $ts1\n"; print "utc ts: $ts2\n"; print "orig ts back: $b1\n"; print "utc ts back: $b2\n"; if ($b1 != $orig || $b2 != $orig) { echo "Error in iso8601 conversions\n"; } else { echo "dateTime OK\n"; } }
ilBMFType_dateTime::compare | ( | $ | date1, | |
$ | date2 = NULL | |||
) |
Definition at line 113 of file class.ilBMFType_dateTime.php.
References toUnixtime().
{ if ($date2 === null) { $date2 = $date1; $date1 = $this->timestamp; } if (!is_numeric($date1)) $date1 = $this->toUnixtime($date1); if (!is_numeric($date2)) $date2 = $this->toUnixtime($date2); if ($date1 != -1 && $date2 != -1) return $date1 - $date2; return -1; }
ilBMFType_dateTime::ilBMFType_dateTime | ( | $ | date = -1 |
) |
Definition at line 36 of file class.ilBMFType_dateTime.php.
References toUnixtime().
{ if ($date == -1) $date = time(); if (gettype($date) == 'integer') { $this->timestamp = $date; } else { $this->timestamp = $this->toUnixtime($date); } }
ilBMFType_dateTime::toSOAP | ( | $ | date = NULL |
) |
Definition at line 47 of file class.ilBMFType_dateTime.php.
References toUTC().
{ return $this->toUTC($date); }
ilBMFType_dateTime::toString | ( | $ | timestamp = 0 |
) |
Definition at line 52 of file class.ilBMFType_dateTime.php.
References $timestamp.
Referenced by _split(), and _test().
{ if (!$timestamp) $timestamp = $this->timestamp; if ($timestamp < 0) return 0; return date('Y-m-d\TH:i:sO',$timestamp); }
ilBMFType_dateTime::toUnixtime | ( | $ | datestr = NULL |
) |
Definition at line 104 of file class.ilBMFType_dateTime.php.
References _split().
Referenced by _test(), compare(), and ilBMFType_dateTime().
{ $regs = $this->_split($datestr); if ($regs) { return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); } return -1; }
ilBMFType_dateTime::toUTC | ( | $ | datestr = NULL |
) |
Definition at line 93 of file class.ilBMFType_dateTime.php.
References _split().
Referenced by _test(), and 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 ''; }
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 24 of file class.ilBMFType_dateTime.php.
ilBMFType_dateTime::$timestamp = -1 |
Definition at line 34 of file class.ilBMFType_dateTime.php.
Referenced by toString().