reference/datetime/dateinterval.xml
9154789dfc9cb8aa5df644bfba5e86c2deba4cb8
...
...
@@ -16,7 +16,8 @@
16
16
<para>
17
17
A date interval stores either a fixed amount of time (in years, months,
18
18
days, hours etc) or a relative time string in the format that
19
-
<classname>DateTime</classname>'s constructor supports.
19
+
<classname>DateTimeImmutable</classname>'s and
20
+
<classname>DateTime</classname>'s constructors support.
20
21
</para>
21
22
<para>
22
23
More specifically, the information in an object of the
...
...
@@ -26,7 +27,12 @@
26
27
<para>
27
28
A common way to create a <classname>DateInterval</classname> object
28
29
is by calculating the difference between two date/time objects through
29
-
<function>DateTimeInterface::diff</function>.
30
+
<methodname>DateTimeInterface::diff</methodname>.
31
+
</para>
32
+
<para>
33
+
Since there is no well defined way to compare date intervals,
34
+
<classname>DateInterval</classname> instances are
35
+
<link linkend="language.operators.comparison.incomparable">incomparable</link>.
30
36
</para>
31
37
</section>
32
38
<!-- }}} -->
...
...
@@ -35,17 +41,11 @@
35
41
&reftitle.classsynopsis;
36
42

37
43
<!-- {{{ Synopsis -->
38
-
<classsynopsis>
44
+
<classsynopsis class="class">
39
45
<ooclass>
40
46
<classname>DateInterval</classname>
41
47
</ooclass>
42
48

43
-
<classsynopsisinfo>
44
-
<ooclass>
45
-
<classname>DateInterval</classname>
46
-
</ooclass>
47
-
</classsynopsisinfo>
48
-

49
49
<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
50
50
<fieldsynopsis>
51
51
<modifier>public</modifier>
...
...
@@ -92,12 +92,22 @@
92
92
<type>mixed</type>
93
93
<varname linkend="dateinterval.props.days">days</varname>
94
94
</fieldsynopsis>
95
+
<fieldsynopsis>
96
+
<modifier>public</modifier>
97
+
<type>bool</type>
98
+
<varname linkend="dateinterval.props.from-string">from_string</varname>
99
+
</fieldsynopsis>
100
+
<fieldsynopsis>
101
+
<modifier>public</modifier>
102
+
<type>string</type>
103
+
<varname linkend="dateinterval.props.date-string">date_string</varname>
104
+
</fieldsynopsis>
95
105
96
106
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
97
-
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])">
107
+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='DateInterval'])">
98
108
<xi:fallback/>
99
109
</xi:include>
100
-
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
110
+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='DateInterval'])">
101
111
<xi:fallback/>
102
112
</xi:include>
103
113
</classsynopsis>
...
...
@@ -107,6 +117,12 @@
107
117
108
118
<section xml:id="dateinterval.props">
109
119
&reftitle.properties;
120
+
<warning>
121
+
<para>
122
+
The available properties listed below depend on PHP version, and should
123
+
be considered as <emphasis>readonly</emphasis>.
124
+
</para>
125
+
</warning>
110
126
<variablelist>
111
127
<varlistentry xml:id="dateinterval.props.y">
112
128
<term><varname>y</varname></term>
...
...
@@ -180,12 +196,36 @@
180
196
<listitem>
181
197
<para>
182
198
If the DateInterval object was created by
183
-
<function>DateTime::diff</function>, then this is the total number of
184
-
days between the start and end dates. Otherwise,
199
+
<methodname>DateTimeImmutable::diff</methodname> or
200
+
<methodname>DateTime::diff</methodname>, then this is the
201
+
total number of full days between the start and end dates. Otherwise,
185
202
<varname>days</varname> will be &false;.
186
203
</para>
187
204
</listitem>
188
205
</varlistentry>
206
+
<varlistentry xml:id="dateinterval.props.from-string">
207
+
<term><varname>from_string</varname></term>
208
+
<listitem>
209
+
<para>
210
+
If the DateInterval object was created by
211
+
<methodname>DateInterval::createFromDateString</methodname>, then
212
+
this property's value will be &true;, and the
213
+
<varname>date_string</varname> property will be populated. Otherwise,
214
+
the value will be &false;, and the <varname>y</varname> to
215
+
<varname>f</varname>, <varname>invert</varname>, and
216
+
<varname>days</varname> properties will be populated.
217
+
</para>
218
+
</listitem>
219
+
</varlistentry>
220
+
<varlistentry xml:id="dateinterval.props.date-string">
221
+
<term><varname>date_string</varname></term>
222
+
<listitem>
223
+
<para>
224
+
The string used as argument to
225
+
<methodname>DateInterval::createFromDateString</methodname>.
226
+
</para>
227
+
</listitem>
228
+
</varlistentry>
189
229
</variablelist>
190
230
</section>
191
231

...
...
@@ -202,6 +242,29 @@
202
242
</thead>
203
243
<tbody>
204
244
<row>
245
+
<entry>8.2.0</entry>
246
+
<entry>
247
+
The <varname>from_string</varname> and <varname>date_string</varname>
248
+
properties were added for <classname>DateInterval</classname>
249
+
instances that were created using the
250
+
<methodname>DateInterval::createFromDateString</methodname> method.
251
+
</entry>
252
+
</row>
253
+
<row>
254
+
<entry>8.2.0</entry>
255
+
<entry>
256
+
Only the <literal>y</literal> to <literal>f</literal>,
257
+
<literal>invert</literal>, and <literal>days</literal> will be visible.
258
+
</entry>
259
+
</row>
260
+
<row>
261
+
<entry>7.4.0</entry>
262
+
<entry>
263
+
<classname>DateInterval</classname> instances are incomparable now;
264
+
previously, all <classname>DateInterval</classname> instances were considered equal.
265
+
</entry>
266
+
</row>
267
+
<row>
205
268
<entry>7.1.0</entry>
206
269
<entry>The <varname>f</varname> property was added.</entry>
207
270
</row>
208
271