mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
225 lines
6.2 KiB
XML
225 lines
6.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<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 a new DatePeriod object</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<constructorsynopsis role="oop">
|
|
<modifier>public</modifier> <methodname>DatePeriod::__construct</methodname>
|
|
<methodparam><type>DateTimeInterface</type><parameter>start</parameter></methodparam>
|
|
<methodparam><type>DateInterval</type><parameter>interval</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>recurrences</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
|
|
</constructorsynopsis>
|
|
<constructorsynopsis role="oop">
|
|
<modifier>public</modifier> <methodname>DatePeriod::__construct</methodname>
|
|
<methodparam><type>DateTimeInterface</type><parameter>start</parameter></methodparam>
|
|
<methodparam><type>DateInterval</type><parameter>interval</parameter></methodparam>
|
|
<methodparam><type>DateTimeInterface</type><parameter>end</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
|
|
</constructorsynopsis>
|
|
<constructorsynopsis role="oop">
|
|
<modifier>public</modifier> <methodname>DatePeriod::__construct</methodname>
|
|
<methodparam><type>string</type><parameter>isostr</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
|
|
</constructorsynopsis>
|
|
<para>
|
|
Creates a new DatePeriod object.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>start</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The start date of the period.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>interval</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The interval between recurrences within the period.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>recurrences</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The number of recurrences. Must be greater than <literal>0</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>end</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The end date of the period.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>isostr</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
An <link
|
|
xlink:href="&url.iso-8601.repeating_intervals;">ISO 8601 repeating interval specification</link>.
|
|
Zero occurrences (<literal>R0/</literal>) are not supported.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
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>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>7.2.19, 7.3.6, 7.4.0</entry>
|
|
<entry>
|
|
<parameter>recurrences</parameter> must be greater than <literal>0</literal> now.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</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>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<simpara>
|
|
Unbound numbers of repetitions as specified by ISO 8601 section 4.5
|
|
"Recurring time interval" are not supported, i.e. neither passing
|
|
<literal>"R/..."</literal> as <parameter>isostr</parameter> nor passing
|
|
&null; as <parameter>end</parameter> would work.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|