reference/datetime/dateperiod.xml
ac83abe55f4da019036de5ec14400d674fa3f9f5
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<phpdoc:classref xml:id="class.dateperiod" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
5
4

6
5
<title>The DatePeriod class</title>
...
...
@@ -25,41 +24,81 @@
25
24
&reftitle.classsynopsis;
26
25

27
26
<!-- {{{ Synopsis -->
28
-
<classsynopsis>
29
-
<ooclass><classname>DatePeriod</classname></ooclass>
30
-

31
-
<!-- {{{ Class synopsis -->
32
-
<classsynopsisinfo>
33
-
<ooclass>
34
-
<classname>DatePeriod</classname>
35
-
</ooclass>
36
-
37
-
<oointerface>
38
-
<interfacename>Traversable</interfacename>
39
-
</oointerface>
40
-
</classsynopsisinfo>
41
-
<!-- }}} -->
27
+
<classsynopsis class="class">
28
+
<ooclass>
29
+
<classname>DatePeriod</classname>
30
+
</ooclass>
31
+

32
+
<oointerface>
33
+
<modifier>implements</modifier>
34
+
<interfacename>IteratorAggregate</interfacename>
35
+
</oointerface>
36
+

42
37
<classsynopsisinfo role="comment">&Constants;</classsynopsisinfo>
43
38
<fieldsynopsis>
39
+
<modifier>public</modifier>
44
40
<modifier>const</modifier>
45
-
<type>integer</type>
41
+
<type>int</type>
46
42
<varname linkend="dateperiod.constants.exclude-start-date">DatePeriod::EXCLUDE_START_DATE</varname>
47
-
<initializer>1</initializer>
43
+
</fieldsynopsis>
44
+
<fieldsynopsis>
45
+
<modifier>public</modifier>
46
+
<modifier>const</modifier>
47
+
<type>int</type>
48
+
<varname linkend="dateperiod.constants.include-end-date">DatePeriod::INCLUDE_END_DATE</varname>
49
+
</fieldsynopsis>
50
+

51
+
<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
52
+
<fieldsynopsis>
53
+
<modifier>public</modifier>
54
+
<modifier>readonly</modifier>
55
+
<type class="union"><type>DateTimeInterface</type><type>null</type></type>
56
+
<varname linkend="dateperiod.props.start">start</varname>
57
+
</fieldsynopsis>
58
+
<fieldsynopsis>
59
+
<modifier>public</modifier>
60
+
<modifier>readonly</modifier>
61
+
<type class="union"><type>DateTimeInterface</type><type>null</type></type>
62
+
<varname linkend="dateperiod.props.current">current</varname>
63
+
</fieldsynopsis>
64
+
<fieldsynopsis>
65
+
<modifier>public</modifier>
66
+
<modifier>readonly</modifier>
67
+
<type class="union"><type>DateTimeInterface</type><type>null</type></type>
68
+
<varname linkend="dateperiod.props.end">end</varname>
69
+
</fieldsynopsis>
70
+
<fieldsynopsis>
71
+
<modifier>public</modifier>
72
+
<modifier>readonly</modifier>
73
+
<type class="union"><type>DateInterval</type><type>null</type></type>
74
+
<varname linkend="dateperiod.props.interval">interval</varname>
75
+
</fieldsynopsis>
76
+
<fieldsynopsis>
77
+
<modifier>public</modifier>
78
+
<modifier>readonly</modifier>
79
+
<type>int</type>
80
+
<varname linkend="dateperiod.props.recurrences">recurrences</varname>
81
+
</fieldsynopsis>
82
+
<fieldsynopsis>
83
+
<modifier>public</modifier>
84
+
<modifier>readonly</modifier>
85
+
<type>bool</type>
86
+
<varname linkend="dateperiod.props.include-start-date">include_start_date</varname>
87
+
</fieldsynopsis>
88
+
<fieldsynopsis>
89
+
<modifier>public</modifier>
90
+
<modifier>readonly</modifier>
91
+
<type>bool</type>
92
+
<varname linkend="dateperiod.props.include-end-date">include_end_date</varname>
48
93
</fieldsynopsis>
49
94

50
95
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
51
-
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])">
52
-
<xi:fallback />
53
-
</xi:include>
54
-
<!--
55
-
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/descendant::db:destructorsynopsis[not(@role='procedural')])">
56
-
<xi:fallback />
96
+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='DatePeriod'])">
97
+
<xi:fallback/>
57
98
</xi:include>
58
-
-->
59
-
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
60
-
<xi:fallback />
99
+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='DatePeriod'])">
100
+
<xi:fallback/>
61
101
</xi:include>
62
-

63
102
</classsynopsis>
64
103
<!-- }}} -->
65
104

...
...
@@ -76,17 +115,173 @@
76
115
</listitem>
77
116
</varlistentry>
78
117

118
+
<varlistentry xml:id="dateperiod.constants.include-end-date">
119
+
<term><constant>DatePeriod::INCLUDE_END_DATE</constant></term>
120
+
<listitem>
121
+
<para>Include end date, used in <function>DatePeriod::__construct</function>.</para>
122
+
</listitem>
123
+
</varlistentry>
124
+

79
125
</variablelist>
80
126
</section>
81
127
<!-- }}} -->
82
128

129
+
<section xml:id="dateperiod.props">
130
+
&reftitle.properties;
131
+
<variablelist>
132
+
<varlistentry xml:id="dateperiod.props.recurrences">
133
+
<term><varname>recurrences</varname></term>
134
+
<listitem>
135
+
<para>
136
+
The minimum amount of instances as retured by the iterator.
137
+
</para>
138
+
<para>
139
+
If the number of recurrences has been explicitly passed through the
140
+
<varname>recurrences</varname> parameter in the constructor of the
141
+
<classname>DatePeriod</classname> instance, then this property contains
142
+
this value, <emphasis>plus</emphasis> one if the start date has not been disabled
143
+
through <constant>DatePeriod::EXCLUDE_START_DATE</constant>,
144
+
<emphasis>plus</emphasis> one if the end date has been enabled through
145
+
<constant>DatePeriod::INCLUDE_END_DATE</constant>.
146
+
</para>
147
+
<para>
148
+
If the number of recurrences has not been explicitly passed, then this
149
+
property contains the minimum number of returned instances. This would
150
+
be <literal>0</literal>, <emphasis>plus</emphasis> one if the start date
151
+
has not been disabled through
152
+
<constant>DatePeriod::EXCLUDE_START_DATE</constant>,
153
+
<emphasis>plus</emphasis> one if the end date has been enabled through
154
+
<constant>DatePeriod::INCLUDE_END_DATE</constant>.
155
+
</para>
156
+
<para>
157
+
<informalexample>
158
+
<programlisting role="php">
159
+
<![CDATA[<?php
160
+
$start = new DateTime('2018-12-31 00:00:00');
161
+
$end = new DateTime('2021-12-31 00:00:00');
162
+
$interval = new DateInterval('P1M');
163
+
$recurrences = 5;
164
+

165
+
// recurrences explicitly set through the constructor
166
+
$period = new DatePeriod($start, $interval, $recurrences, DatePeriod::EXCLUDE_START_DATE);
167
+
echo $period->recurrences, "\n";
168
+

169
+
$period = new DatePeriod($start, $interval, $recurrences);
170
+
echo $period->recurrences, "\n";
171
+

172
+
$period = new DatePeriod($start, $interval, $recurrences, DatePeriod::INCLUDE_END_DATE);
173
+
echo $period->recurrences, "\n";
174
+

175
+
// recurrences not set in the constructor
176
+
$period = new DatePeriod($start, $interval, $end);
177
+
echo $period->recurrences, "\n";
178
+

179
+
$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
180
+
echo $period->recurrences, "\n";
181
+
?>]]>
182
+
</programlisting>
183
+
&example.outputs;
184
+
<screen role="php">
185
+
5
186
+
6
187
+
7
188
+
1
189
+
0
190
+
</screen>
191
+
</informalexample>
192
+
</para>
193
+
<para>
194
+
See also <methodname>DatePeriod::getRecurrences</methodname>.
195
+
</para>
196
+
</listitem>
197
+
</varlistentry>
198
+
<varlistentry xml:id="dateperiod.props.include-end-date">
199
+
<term><varname>include_end_date</varname></term>
200
+
<listitem>
201
+
<para>
202
+
Whether to include the end date in the set of recurring dates or not.
203
+
</para>
204
+
</listitem>
205
+
</varlistentry>
206
+
<varlistentry xml:id="dateperiod.props.include-start-date">
207
+
<term><varname>include_start_date</varname></term>
208
+
<listitem>
209
+
<para>
210
+
Whether to include the start date in the set of recurring dates or not.
211
+
</para>
212
+
</listitem>
213
+
</varlistentry>
214
+
<varlistentry xml:id="dateperiod.props.start">
215
+
<term><varname>start</varname></term>
216
+
<listitem>
217
+
<para>
218
+
The start date of the period.
219
+
</para>
220
+
</listitem>
221
+
</varlistentry>
222
+
<varlistentry xml:id="dateperiod.props.current">
223
+
<term><varname>current</varname></term>
224
+
<listitem>
225
+
<para>
226
+
During iteration this will contain the current date within the period.
227
+
</para>
228
+
</listitem>
229
+
</varlistentry>
230
+
<varlistentry xml:id="dateperiod.props.end">
231
+
<term><varname>end</varname></term>
232
+
<listitem>
233
+
<para>
234
+
The end date of the period.
235
+
</para>
236
+
</listitem>
237
+
</varlistentry>
238
+
<varlistentry xml:id="dateperiod.props.interval">
239
+
<term><varname>interval</varname></term>
240
+
<listitem>
241
+
<para>
242
+
An ISO 8601 repeating interval specification.
243
+
</para>
244
+
</listitem>
245
+
</varlistentry>
246
+
</variablelist>
247
+
</section>
248
+

249
+
<section role="changelog">
250
+
&reftitle.changelog;
251
+
<informaltable>
252
+
<tgroup cols="2">
253
+
<thead>
254
+
<row>
255
+
<entry>&Version;</entry>
256
+
<entry>&Description;</entry>
257
+
</row>
258
+
</thead>
259
+
<tbody>
260
+
<row>
261
+
<entry>8.2.0</entry>
262
+
<entry>
263
+
The <constant>DatePeriod::INCLUDE_END_DATE</constant> constant and
264
+
<property>include_end_date</property> property have been added.
265
+
</entry>
266
+
</row>
267
+
<row>
268
+
<entry>8.0.0</entry>
269
+
<entry>
270
+
<classname>DatePeriod</classname> implements
271
+
<interfacename>IteratorAggregate</interfacename> now.
272
+
Previously, <interfacename>Traversable</interfacename> was implemented instead.
273
+
</entry>
274
+
</row>
275
+
</tbody>
276
+
</tgroup>
277
+
</informaltable>
278
+
</section>
83
279

84
280
</partintro>
85
281

86
282
&reference.datetime.entities.dateperiod;
87
283

88
284
</phpdoc:classref>
89
-

90
285
<!-- Keep this comment at the end of the file
91
286
Local variables:
92
287
mode: sgml
93
288