mirror of
https://github.com/php/doc-ru.git
synced 2025-08-16 18:22:04 +00:00
270 lines
13 KiB
XML
270 lines
13 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: fce2e1a41a75a140ed5dee42c368488542864a8e Maintainer: sergey Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<refentry xml:id="intldateformatter.create" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>IntlDateFormatter::create</refname>
|
||
<refname>datefmt_create</refname>
|
||
<refname>IntlDateFormatter::__construct</refname>
|
||
<refpurpose>Создаёт средство форматирования даты</refpurpose>
|
||
</refnamediv>
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<para>
|
||
&style.oop;
|
||
</para>
|
||
<methodsynopsis role="oop">
|
||
<modifier>public</modifier> <modifier>static</modifier> <type class="union"><type>IntlDateFormatter</type><type>null</type></type><methodname>IntlDateFormatter::create</methodname>
|
||
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>locale</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>dateType</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>timeType</parameter></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>IntlTimeZone</type><type>DateTimeZone</type><type>string</type><type>null</type></type><parameter>timezone</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>IntlCalendar</type><type>int</type><type>null</type></type><parameter>calendar</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type>string</type><parameter>pattern</parameter><initializer>""</initializer></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
&style.oop; (конструктор)
|
||
</para>
|
||
<constructorsynopsis>
|
||
<modifier>public</modifier> <methodname>IntlDateFormatter::__construct</methodname>
|
||
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>locale</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>dateType</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>timeType</parameter></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>IntlTimeZone</type><type>DateTimeZone</type><type>string</type><type>null</type></type><parameter>timezone</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>IntlCalendar</type><type>int</type><type>null</type></type><parameter>calendar</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type>string</type><parameter>pattern</parameter><initializer>""</initializer></methodparam>
|
||
</constructorsynopsis>
|
||
<para>
|
||
&style.procedural;
|
||
</para>
|
||
<methodsynopsis role="procedural">
|
||
<type class="union"><type>IntlDateFormatter</type><type>null</type></type><methodname>datefmt_create</methodname>
|
||
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>locale</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>dateType</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>timeType</parameter></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>IntlTimeZone</type><type>DateTimeZone</type><type>string</type><type>null</type></type><parameter>timezone</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>IntlCalendar</type><type>int</type><type>null</type></type><parameter>calendar</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type>string</type><parameter>pattern</parameter><initializer>""</initializer></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Создаёт средство форматирования даты.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>locale</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Языковой стандарт, используемый при форматировании или синтаксическом анализе
|
||
или &null; для использования значения, указанного в ini-настройке
|
||
<link linkend="ini.intl.default-locale">intl.default_locale</link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>dateType</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Тип даты (<constant>none</constant>, <constant>short</constant>,
|
||
<constant>medium</constant>, <constant>long</constant>,
|
||
<constant>full</constant>).
|
||
Одна из <link linkend="intl.intldateformatter-constants">констант IntlDateFormatter</link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>timeType</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Тип времени (<constant>none</constant>, <constant>short</constant>,
|
||
<constant>medium</constant>, <constant>long</constant>,
|
||
<constant>full</constant>).
|
||
Одна из <link linkend="intl.intldateformatter-constants">констант IntlDateFormatter</link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>timezone</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Идентификатор часового пояса. По умолчанию (и тот, который используется, если указан &null;) - это тот,
|
||
который возвращается <function>date_default_timezone_get</function> или, если применимо,
|
||
объект <classname>IntlCalendar</classname>, указанный в параметре <parameter>calendar</parameter>.
|
||
Этот идентификатор должен быть корректным идентификатором в базе данных ICU или идентификатором,
|
||
представляющим явное смещение, например, <literal>GMT-05:30</literal>.
|
||
</para>
|
||
<para>
|
||
Также может быть объект <classname>IntlTimeZone</classname> или <classname>DateTimeZone</classname>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>calendar</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Календарь для форматирования или анализа. Значение по умолчанию - &null;,
|
||
что соответствует <constant>IntlDateFormatter::GREGORIAN</constant>.
|
||
Может быть одна из <link linkend="intl.intldateformatter-constants.calendartypes">констант IntlDateFormatter</link>
|
||
или объект <classname>IntlCalendar</classname>.
|
||
Любой переданный объект <classname>IntlCalendar</classname> будет клонирован; он не будет изменён <classname>IntlDateFormatter</classname>.
|
||
Это определит используемый тип календаря (григорианский, исламский, персидский и т.д.) и, если в параметре <parameter>timezone</parameter>
|
||
указано значение &null;, также определит используемый часовой пояс.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>pattern</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Необязательный шаблон для использования при форматировании или анализе.
|
||
Возможные шаблоны задокументированы по адресу
|
||
<link xlink:href="&url.icu.datepattern;">&url.icu.datepattern;</link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
Созданный объект <classname>IntlDateFormatter</classname> или &null; в случае возникновения ошибки.
|
||
</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>5.5.0/PECL 3.0.0</entry>
|
||
<entry>
|
||
<para>
|
||
Объект <classname>IntlCalendar</classname> допускается в параметре
|
||
<parameter>calendar</parameter>.
|
||
</para>
|
||
<para>
|
||
Объекты <classname>IntlTimeZone</classname> и
|
||
<classname>DateTimeZone</classname> допускаются в параметре
|
||
<parameter>timezone</parameter>.
|
||
</para>
|
||
<para>
|
||
Недопустимые идентификаторы часового пояса (включая пустые строки)
|
||
больше не допускаются в параметре <parameter>timezone</parameter>.
|
||
</para>
|
||
<para>
|
||
Если в параметре <parameter>timezone</parameter> указано значение &null;,
|
||
идентификатор часового пояса, заданный <function>date_default_timezone_get</function>,
|
||
будет использоваться вместо значения ICU по умолчанию.
|
||
</para>
|
||
</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</informaltable>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<example>
|
||
<title>Пример использования <function>datefmt_create</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles', IntlDateFormatter::GREGORIAN );
|
||
echo "First Formatted output is ".datefmt_format( $fmt , 0);
|
||
$fmt = datefmt_create( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
|
||
echo "Second Formatted output is ".datefmt_format( $fmt , 0);
|
||
|
||
$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN ,"MM/dd/yyyy");
|
||
echo "First Formatted output with pattern is ".datefmt_format( $fmt , 0);
|
||
$fmt = datefmt_create( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN ,"MM/dd/yyyy");
|
||
echo "Second Formatted output with pattern is ".datefmt_format( $fmt , 0);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</example>
|
||
<example>
|
||
<title>OO example</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
$fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
|
||
echo "Первый форматированный вывод: ".$fmt->format(0);
|
||
$fmt = new IntlDateFormatter( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
|
||
echo "Второй форматированный вывод: ".$fmt->format(0);
|
||
|
||
$fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN ,"MM/dd/yyyy");
|
||
echo "Первый форматированный вывод с шаблоном: ".$fmt->format(0);
|
||
$fmt = new IntlDateFormatter( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||
'America/Los_Angeles',IntlDateFormatter::GREGORIAN , "MM/dd/yyyy");
|
||
echo "Второй форматированный вывод с шаблоном: ".$fmt->format(0);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</example>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
Первый форматированный вывод: Wednesday, December 31, 1969 4:00:00 PM PT
|
||
Второй форматированный вывод: Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
|
||
Первый форматированный вывод с шаблоном: 12/31/1969
|
||
Второй форматированный вывод с шаблоном: 12/31/1969
|
||
]]>
|
||
</screen>
|
||
</refsect1>
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<para>
|
||
<simplelist>
|
||
<member><function>datefmt_format</function></member>
|
||
<member><function>datefmt_parse</function></member>
|
||
<member><function>datefmt_get_error_code</function></member>
|
||
<member><function>datefmt_get_error_message</function></member>
|
||
</simplelist>
|
||
</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
|
||
-->
|