php-doc-en/reference/intl/intlcalendar/add.xml
Gustavo André dos Santos Lopes b72281bf1c Fully document IntlCalendar methods until ::fromDateTime()
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330586 c90b9560-bf6c-de11-be94-00142212c4b1
2013-06-21 00:48:30 +00:00

116 lines
3.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="intlcalendar.add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>IntlCalendar::add</refname>
<refpurpose>Add a (signed) amount of time to a field</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>bool</type><methodname>IntlCalendar::add</methodname>
<methodparam><type>int</type><parameter>field</parameter></methodparam>
<methodparam><type>int</type><parameter>amount</parameter></methodparam>
</methodsynopsis>
<para>
Add a signed amount to a field. Adding a positive amount allows advances in
time, even if the numeric value of the field decreases (e.g. when working
with years in BC dates).
</para>
<para>
Other fields may need to adjusted for instance, adding a month to the 31st
of January will result in the 28th (or 29th) of February. Contrary to
<function>IntlCalendar::roll</function>, when a value wraps around, more
significant fields may change. For instance, adding a day to the 31st of
January will result in the 1st of February, not the 1st of Janurary.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>field</parameter></term>
<listitem>
&reference.intl.incfieldparam;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>amount</parameter></term>
<listitem>
<para>
The signed amount to add to the current field. If the amount is positive,
the instant will be moved forward; if it is negative, the instant wil be
moved into the past. The unit is implicit to the field type. For instance,
hours for <constant>IntlCalendar::FIELD_HOUR_OF_DAY</constant>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; on success&return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>IntlCalendar::add</function></title>
<programlisting role="php">
<![CDATA[
<?php
ini_set('intl.default_locale', 'fr_FR');
ini_set('date.timezone', 'UTC');
$cal = new IntlGregorianCalendar(2012, 0 /* January */, 31);
echo IntlDateFormatter::formatObject($cal), "\n";
$cal->add(IntlCalendar::FIELD_MONTH, 1);
echo IntlDateFormatter::formatObject($cal), "\n";
$cal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1);
echo IntlDateFormatter::formatObject($cal), "\n";
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
31 janv. 2012 00:00:00
29 févr. 2012 00:00:00
1 mars 2012 00:00:00
]]>
</screen>
</example>
</para>
</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
-->