ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBMFType_dateTime Class Reference
+ Collaboration diagram for ilBMFType_dateTime:

Public Member Functions

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

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

◆ _split()

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.

167 {
168 if (!$datestr)
169 $datestr = $this->toString();
170 else if (gettype($datestr) == 'integer')
171 $datestr = $this->toString($datestr);
172
173 if (ereg($this->ereg_iso8601,$datestr,$regs)) {
174 if ($regs[8] != '' && $regs[8] != 'Z') {
175 $op = substr($regs[8],0,1);
176 $h = substr($regs[8],1,2);
177 if (strstr($regs[8],':')) {
178 $m = substr($regs[8],4,2);
179 } else {
180 $m = substr($regs[8],3,2);
181 }
182 if ($op == '+') {
183 $regs[4] = $regs[4] - $h;
184 if ($regs[4] < 0) $regs[4] += 24;
185 $regs[5] = $regs[5] - $m;
186 if ($regs[5] < 0) $regs[5] += 60;
187 } else {
188 $regs[4] = $regs[4] + $h;
189 if ($regs[4] > 23) $regs[4] -= 24;
190 $regs[5] = $regs[5] + $m;
191 if ($regs[5] > 59) $regs[5] -= 60;
192 }
193 }
194 return $regs;
195 }
196 return FALSE;
197 }
toString($timestamp=0)
Converts this object or a timestamp to an ISO 8601 date/time string.
$h

References $h, and toString().

Referenced by toUnixtime(), and toUTC().

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

◆ compare()

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.

258 {
259 if (is_null($date2)) {
260 $date2 = $date1;
261 $date1 = $this->timestamp;
262 }
263 if (!is_int($date1)) {
264 $date1 = $this->toUnixtime($date1);
265 }
266 if (!is_int($date2)) {
267 $date2 = $this->toUnixtime($date2);
268 }
269
270 if ($date1 != -1 && $date2 != -1) {
271 return $date1 - $date2;
272 }
273
274 return -1;
275 }
toUnixtime($datestr=null)
Returns a unix timestamp.

References $timestamp, and toUnixtime().

+ Here is the call graph for this function:

◆ ilBMFType_dateTime()

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.

65 {
66 if ($date == -1) {
67 $this->timestamp = time();
68 } elseif (is_int($date)) {
69 $this->timestamp = $date;
70 } else {
71 $this->timestamp = $this->toUnixtime($date);
72 }
73 }

References toUnixtime().

+ Here is the call graph for this function:

◆ toSOAP()

ilBMFType_dateTime::toSOAP (   $date = NULL)

Alias of ilBMFType_dateTime::toUTC.

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

79 {
80 return $this->toUTC($date);
81 }
toUTC($datestr=null)
Returns an ISO 8601 formatted UTC date/time string.

References toUTC().

+ Here is the call graph for this function:

◆ toString()

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.

91 {
92 if (!$timestamp) {
94 }
95 if ($timestamp < 0) {
96 return 0;
97 }
98
99 return date('Y-m-d\TH:i:sO', $timestamp);
100 }

References $timestamp.

Referenced by _split().

+ Here is the caller graph for this function:

◆ toUnixtime()

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.

231 {
232 $regs = $this->_split($datestr);
233 if ($regs) {
234/* Databay: Changes for BMF */
235/* return strtotime(sprintf('%04d-%02d-%02d %02d:%02d:%02dZ',
236 $regs[1],
237 $regs[2],
238 $regs[3],
239 $regs[4],
240 $regs[5],
241 $regs[6]));*/
242 return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
243 }
244 return -1;
245 }
_split($datestr)
Splits a date/time into its components.

References _split().

Referenced by compare(), and ilBMFType_dateTime().

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

◆ toUTC()

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.

207 {
208 $regs = $this->_split($datestr);
209
210 if ($regs) {
211 return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',
212 $regs[1],
213 $regs[2],
214 $regs[3],
215 $regs[4],
216 $regs[5],
217 $regs[6]);
218 }
219
220 return '';
221 }

References _split().

Referenced by toSOAP().

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

Field Documentation

◆ $ereg_iso8601

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.

◆ $timestamp

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: