DateInterval: weeks and days can be combined since 8.0.0 (#637)

Closes #633
This commit is contained in:
Sergey Panteleev 2021-05-29 08:59:50 +03:00 committed by GitHub
parent e4b889a3e8
commit 3263a6218e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -65,8 +65,8 @@
<row>
<entry><literal>W</literal></entry>
<entry>
weeks. These get converted into days,
so can not be combined with <literal>D</literal>.
weeks. Converted into days.
Prior to PHP 8.0.0, can not be combined with <literal>D</literal>.
</entry>
</row>
<row>
@ -128,6 +128,28 @@
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
<literal>W</literal> can be combined with <literal>D</literal>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
@ -137,32 +159,87 @@
<![CDATA[
<?php
$interval = new DateInterval('P2Y4DT6H8M');
$interval = new DateInterval('P1W2D');
var_dump($interval);
?>
]]>
</programlisting>
&example.outputs;
&example.outputs.8;
<screen role="php">
<![CDATA[
object(DateInterval)#1 (8) {
object(DateInterval)#1 (16) {
["y"]=>
int(2)
int(0)
["m"]=>
int(0)
["d"]=>
int(4)
int(9)
["h"]=>
int(6)
int(0)
["i"]=>
int(8)
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
]]>
</screen>
&example.outputs.7;
<screen role="php">
<![CDATA[
object(DateInterval)#1 (16) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(2)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
]]>
</screen>