ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDateList Class Reference

List of dates. More...

+ Inheritance diagram for ilDateList:
+ Collaboration diagram for ilDateList:

Public Member Functions

 __construct ($a_type)
 Constructor. More...
 
 rewind ()
 Iterator Rewind. More...
 
 current ()
 Iterator Current. More...
 
 key ()
 Iterator key. More...
 
 next ()
 Iterator next. More...
 
 valid ()
 Iterator valid. More...
 
 get ()
 get More...
 
 getAtPosition ($a_pos)
 get item at specific position More...
 
 add ($date)
 add a date to the date list More...
 
 merge (ilDateList $other_list)
 Merge two lists. More...
 
 remove (ilDateTime $remove)
 remove from list More...
 
 removeByDAY (ilDateTime $remove)
 
 sort ()
 Sort list. More...
 
 __toString ()
 to string More...
 

Data Fields

const TYPE_DATE = 1
 
const TYPE_DATETIME = 2
 

Protected Attributes

 $list_item = array()
 
 $type
 

Detailed Description

List of dates.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilDateList.php.

Constructor & Destructor Documentation

◆ __construct()

ilDateList::__construct (   $a_type)

Constructor.

@access public

Parameters
typelist of TYPE_DATE or type TYPE_DATETIME

Definition at line 50 of file class.ilDateList.php.

51 {
52 $this->type = $a_type;
53 $this->list_item = array();
54 }
$a_type
Definition: workflow.php:92

References $a_type.

Member Function Documentation

◆ __toString()

ilDateList::__toString ( )

to string

@access public

Definition at line 203 of file class.ilDateList.php.

204 {
205 $out = '<br />';
206 foreach ($this->get() as $date) {
207 $out .= $date->get(IL_CAL_DATETIME, '', 'Europe/Berlin') . '<br/>';
208 }
209 return $out;
210 }
const IL_CAL_DATETIME

References $out, and IL_CAL_DATETIME.

◆ add()

ilDateList::add (   $date)

add a date to the date list

@access public

Parameters
objectilDateTime

Definition at line 138 of file class.ilDateList.php.

139 {
140 // the unix time is the key.
141 // It's casted to string because array_merge overwrites only string keys
142 // @see merge
143 $this->list_item[(string) $date->get(IL_CAL_UNIX)] = clone $date;
144 }
const IL_CAL_UNIX

References IL_CAL_UNIX.

Referenced by merge().

+ Here is the caller graph for this function:

◆ current()

ilDateList::current ( )

Iterator Current.

Returns

Definition at line 70 of file class.ilDateList.php.

71 {
72 return current($this->list_item);
73 }
current()
Iterator Current.

References current().

Referenced by current(), and valid().

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

◆ get()

ilDateList::get ( )

get

@access public

Definition at line 109 of file class.ilDateList.php.

110 {
111 return $this->list_item ? $this->list_item : array();
112 }

Referenced by ilCalendarRecurrenceCalculator\applyBYDAYRules(), ilCalendarRecurrenceCalculator\applyBYMONTHDAYRules(), ilCalendarRecurrenceCalculator\applyBYMONTHRules(), ilCalendarRecurrenceCalculator\applyBYWEEKNORules(), ilCalendarRecurrenceCalculator\applyBYYEARDAYRules(), and merge().

+ Here is the caller graph for this function:

◆ getAtPosition()

ilDateList::getAtPosition (   $a_pos)

get item at specific position

@access public

Parameters
intposition (first position is 1)

Definition at line 121 of file class.ilDateList.php.

122 {
123 $counter = 1;
124 foreach ($this->get() as $item) {
125 if ($counter++ == $a_pos) {
126 return $item;
127 }
128 }
129 return null;
130 }
$counter

References $counter.

◆ key()

ilDateList::key ( )

Iterator key.

Returns

Definition at line 79 of file class.ilDateList.php.

80 {
81 return key($this->list_item);
82 }
key()
Iterator key.

References key().

Referenced by key().

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

◆ merge()

ilDateList::merge ( ilDateList  $other_list)

Merge two lists.

@access public

Parameters
objectilDateList

Definition at line 153 of file class.ilDateList.php.

154 {
155 foreach ($other_list->get() as $new_date) {
156 $this->add($new_date);
157 }
158 }
add($date)
add a date to the date list

References add(), and get().

+ Here is the call graph for this function:

◆ next()

ilDateList::next ( )

Iterator next.

Returns

Definition at line 88 of file class.ilDateList.php.

89 {
90 return next($this->list_item);
91 }
next()
Iterator next.

References next().

Referenced by next().

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

◆ remove()

ilDateList::remove ( ilDateTime  $remove)

remove from list

@access public

Parameters
objectilDateTime

Definition at line 167 of file class.ilDateList.php.

168 {
169 $unix_remove = $remove->get(IL_CAL_UNIX);
170 if (isset($this->list_item[$unix_remove])) {
171 unset($this->list_item[$unix_remove]);
172 }
173 return true;
174 }
get($a_format, $a_format_str='', $a_tz='')
get formatted date

References IL_CAL_UNIX.

◆ removeByDAY()

ilDateList::removeByDAY ( ilDateTime  $remove)

Definition at line 176 of file class.ilDateList.php.

177 {
178 foreach ($this->list_item as $key => $dt) {
179 if (ilDateTime::_equals($remove, $dt, IL_CAL_DAY, ilTimeZone::UTC)) {
180 unset($this->list_item[$key]);
181 }
182 }
183 return true;
184 }
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
$key
Definition: croninfo.php:18

References $key, ilDateTime\_equals(), IL_CAL_DAY, and ilTimeZone\UTC.

+ Here is the call graph for this function:

◆ rewind()

ilDateList::rewind ( )

Iterator Rewind.

Returns

Definition at line 61 of file class.ilDateList.php.

62 {
63 reset($this->list_item);
64 }

◆ sort()

ilDateList::sort ( )

Sort list.

@access public

Definition at line 192 of file class.ilDateList.php.

193 {
194 return ksort($this->list_item, SORT_NUMERIC);
195 }

Referenced by ilCalendarRecurrenceCalculator\applyBYSETPOSRules().

+ Here is the caller graph for this function:

◆ valid()

ilDateList::valid ( )

Iterator valid.

Returns

Definition at line 97 of file class.ilDateList.php.

98 {
99 return $this->current() !== false;
100 }

References current().

+ Here is the call graph for this function:

Field Documentation

◆ $list_item

ilDateList::$list_item = array()
protected

Definition at line 39 of file class.ilDateList.php.

◆ $type

ilDateList::$type
protected

Definition at line 41 of file class.ilDateList.php.

◆ TYPE_DATE

◆ TYPE_DATETIME

const ilDateList::TYPE_DATETIME = 2

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