Fix doc bug #62486 (Missing documentation for DatePeriod).

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@326735 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Adam Harvey 2012-07-20 09:39:42 +00:00
parent fb16d269be
commit 4174a16888
2 changed files with 89 additions and 9 deletions

View file

@ -12,7 +12,11 @@
<section xml:id="dateperiod.intro">
&reftitle.intro;
<para>
Representation of date period.
Represents a date period.
</para>
<para>
A date period allows iteration over a set of dates and times, recurring at
regular intervals, over a given period.
</para>
</section>
<!-- }}} -->

View file

@ -4,7 +4,7 @@
<refentry xml:id="dateperiod.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DatePeriod::__construct</refname>
<refpurpose>Creates new DatePeriod object</refpurpose>
<refpurpose>Creates a new DatePeriod object</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -29,7 +29,7 @@
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</constructorsynopsis>
<para>
Creates new DatePeriod object.
Creates a new DatePeriod object.
</para>
</refsect1>
@ -41,7 +41,7 @@
<term><parameter>start</parameter></term>
<listitem>
<para>
Start date.
The start date of the period.
</para>
</listitem>
</varlistentry>
@ -49,7 +49,7 @@
<term><parameter>interval</parameter></term>
<listitem>
<para>
Interval.
The interval between recurrences within the period.
</para>
</listitem>
</varlistentry>
@ -57,7 +57,7 @@
<term><parameter>recurrences</parameter></term>
<listitem>
<para>
Number of recurrences.
The number of recurrences.
</para>
</listitem>
</varlistentry>
@ -65,7 +65,7 @@
<term><parameter>end</parameter></term>
<listitem>
<para>
End date.
The end date of the period.
</para>
</listitem>
</varlistentry>
@ -73,7 +73,7 @@
<term><parameter>isostr</parameter></term>
<listitem>
<para>
String containing the ISO interval.
An ISO 8601 repeating interval specification.
</para>
</listitem>
</varlistentry>
@ -81,7 +81,9 @@
<term><parameter>options</parameter></term>
<listitem>
<para>
Can be set to <constant>DatePeriod::EXCLUDE_START_DATE</constant>.
Can be set to <constant>DatePeriod::EXCLUDE_START_DATE</constant> to
exclude the start date from the set of recurring dates within the
period.
</para>
</listitem>
</varlistentry>
@ -89,6 +91,80 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>DatePeriod example</title>
<programlisting role="php">
<![CDATA[
<?php
$start = new DateTime('2012-07-01');
$interval = new DateInterval('P7D');
$end = new DateTime('2012-07-31');
$recurrences = 4;
$iso = 'R4/2012-07-01T00:00:00Z/P7D';
// All of these periods are equivalent.
$period = new DatePeriod($start, $interval, $recurrences);
$period = new DatePeriod($start, $interval, $end);
$period = new DatePeriod($iso);
// By iterating over the DatePeriod object, all of the
// recurring dates within that period are printed.
foreach ($period as $date) {
echo $date->format('Y-m-d')."\n";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2012-07-01
2012-07-08
2012-07-15
2012-07-22
2012-07-29
]]>
</screen>
</example>
</para>
<para>
<example>
<title>DatePeriod example with <constant>DatePeriod::EXCLUDE_START_DATE</constant></title>
<programlisting role="php">
<![CDATA[
<?php
$start = new DateTime('2012-07-01');
$interval = new DateInterval('P7D');
$end = new DateTime('2012-07-31');
$period = new DatePeriod($start, $interval, $end,
DatePeriod::EXCLUDE_START_DATE);
// By iterating over the DatePeriod object, all of the
// recurring dates within that period are printed.
// Note that, in this case, 2012-07-01 is not printed.
foreach ($period as $date) {
echo $date->format('Y-m-d')."\n";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2012-07-08
2012-07-15
2012-07-22
2012-07-29
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file