Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion reference/datetime/book.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: takagi Status: ready -->
<!-- EN-Revision: 09e39c586d1fa47d499807f911ff92d69d175db7 Maintainer: takagi Status: ready -->
<!-- CREDITS: shimooka,hirokawa,mumumu -->

<book xml:id="book.datetime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
Expand Down Expand Up @@ -53,6 +53,7 @@
&reference.datetime.datetimezone;
&reference.datetime.dateinterval;
&reference.datetime.dateperiod;
&reference.datetime.time.duration;

&reference.datetime.reference;

Expand Down Expand Up @@ -83,6 +84,9 @@
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara><exceptionname>Time\TimeException</exceptionname> (extends <exceptionname>Exception</exceptionname>)</simpara>
</listitem>
</itemizedlist>
</article>

Expand All @@ -98,6 +102,7 @@
&reference.datetime.datemalformedintervalstringexception;
&reference.datetime.datemalformedperiodstringexception;
&reference.datetime.datemalformedstringexception;
&reference.datetime.time.timeexception;

</book>

Expand Down
7 changes: 6 additions & 1 deletion reference/datetime/dateinterval.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 18c0977d5ec59f4207cb0b306c5473508bf640ed Maintainer: takagi Status: ready -->
<!-- EN-Revision: 09e39c586d1fa47d499807f911ff92d69d175db7 Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->
<reference xml:id="class.dateinterval" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">

Expand Down Expand Up @@ -52,6 +52,11 @@
のインスタンスは
<link linkend="language.operators.comparison.incomparable">比較できません</link>。
</para>
<simpara>
タイムアウトなど、暦の単位を持たず、長さが一定で比較できる経過時間を扱うには、
代わりに PHP 8.6.0 以降で利用できる <classname>Time\Duration</classname>
を使ってください。
</simpara>
</section>

<section xml:id="dateinterval.synopsis">
Expand Down
34 changes: 33 additions & 1 deletion reference/datetime/datetime/createfromtimestamp.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 726154e3c846bc0e16c60542377ea806df32e55d Maintainer: KentarouTakeda Status: ready -->
<!-- EN-Revision: 69ce9dc901258987257483724c4b7d79c501c66c Maintainer: KentarouTakeda Status: ready -->
<refentry xml:id="datetime.createfromtimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTime::createFromTimestamp</refname>
Expand All @@ -17,6 +17,15 @@
<simpara>
Unix タイムスタンプからインスタンスを生成します。
</simpara>
<simpara>
返されるオブジェクトのタイムゾーンは、
<code>new DateTime('@' . $timestamp)</code> と同様、
常に UTC オフセット <literal>+00:00</literal> になります。
<function>date_default_timezone_get</function>
が返すデフォルトのタイムゾーンは使われません。
別のタイムゾーンでの日時を得るには、返されたオブジェクトの
<methodname>DateTime::setTimezone</methodname> を呼び出してください。
</simpara>
</refsect1>

<refsect1 role="parameters">
Expand Down Expand Up @@ -67,6 +76,29 @@ echo $date->format('Y-m-d H:i:s.u');
<screen>
<![CDATA[
1970-01-01 00:02:03.456789
]]>
</screen>
</example>
<example xml:id="datetime.createfromtimestamp.example.timezone">
<title>結果をデフォルトのタイムゾーンに変換する</title>
<programlisting role="php">
<![CDATA[
<?php
date_default_timezone_set('Europe/Amsterdam');

$date = DateTime::createFromTimestamp(1700000000);
echo $date->format('Y-m-d H:i:s P e'), "\n";

$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
echo $date->format('Y-m-d H:i:s P e'), "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2023-11-14 22:13:20 +00:00 +00:00
2023-11-14 23:13:20 +01:00 Europe/Amsterdam
]]>
</screen>
</example>
Expand Down
35 changes: 34 additions & 1 deletion reference/datetime/datetime/setisodate.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 02ff7fef5b34cf8f5395180d9d39fb64d9398d00 Maintainer: takagi Status: ready -->
<!-- EN-Revision: 506a93caec897989ad6e1d11a9fcbd53f5d8047b Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->

<refentry xml:id="datetime.setisodate" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down Expand Up @@ -78,6 +78,39 @@
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされます。
たとえば、子クラスのコンストラクタが親クラスのコンストラクタを呼び出さない場合です。
</simpara>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされるようになりました。
これより前のバージョンでは、<exceptionname>Error</exceptionname> がスローされていました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
Expand Down
19 changes: 18 additions & 1 deletion reference/datetime/datetime/settime.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 02ff7fef5b34cf8f5395180d9d39fb64d9398d00 Maintainer: takagi Status: ready -->
<!-- EN-Revision: 506a93caec897989ad6e1d11a9fcbd53f5d8047b Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->

<refentry xml:id="datetime.settime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down Expand Up @@ -88,6 +88,15 @@
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされます。
たとえば、子クラスのコンストラクタが親クラスのコンストラクタを呼び出さない場合です。
</simpara>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
Expand All @@ -99,6 +108,14 @@
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされるようになりました。
これより前のバージョンでは、<exceptionname>Error</exceptionname> がスローされていました。
</entry>
</row>
<row>
<entry>8.1.0</entry>
<entry>
Expand Down
35 changes: 34 additions & 1 deletion reference/datetime/datetime/settimestamp.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 726154e3c846bc0e16c60542377ea806df32e55d Maintainer: takagi Status: ready -->
<!-- EN-Revision: 506a93caec897989ad6e1d11a9fcbd53f5d8047b Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->

<refentry xml:id="datetime.settimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down Expand Up @@ -61,6 +61,39 @@
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされます。
たとえば、子クラスのコンストラクタが親クラスのコンストラクタを呼び出さない場合です。
</simpara>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされるようになりました。
これより前のバージョンでは、<exceptionname>Error</exceptionname> がスローされていました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
Expand Down
35 changes: 34 additions & 1 deletion reference/datetime/datetime/settimezone.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 525aa5f198d482c0d03be54ddee5af13b376ab99 Maintainer: takagi Status: ready -->
<!-- EN-Revision: 506a93caec897989ad6e1d11a9fcbd53f5d8047b Maintainer: takagi Status: ready -->
<!-- Credits: mumumu -->

<refentry xml:id="datetime.settimezone" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down Expand Up @@ -62,6 +62,39 @@
</simpara>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされます。
たとえば、子クラスのコンストラクタが親クラスのコンストラクタを呼び出さない場合です。
</simpara>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされるようになりました。
これより前のバージョンでは、<exceptionname>Error</exceptionname> がスローされていました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<example>
Expand Down
34 changes: 33 additions & 1 deletion reference/datetime/datetimeimmutable/createfromtimestamp.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 726154e3c846bc0e16c60542377ea806df32e55d Maintainer: KentarouTakeda Status: ready -->
<!-- EN-Revision: 69ce9dc901258987257483724c4b7d79c501c66c Maintainer: KentarouTakeda Status: ready -->
<refentry xml:id="datetimeimmutable.createfromtimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTimeImmutable::createFromTimestamp</refname>
Expand All @@ -17,6 +17,15 @@
<simpara>
Unix タイムスタンプからインスタンスを生成します。
</simpara>
<simpara>
返されるオブジェクトのタイムゾーンは、
<code>new DateTimeImmutable('@' . $timestamp)</code> と同様、
常に UTC オフセット <literal>+00:00</literal> になります。
<function>date_default_timezone_get</function>
が返すデフォルトのタイムゾーンは使われません。
別のタイムゾーンでの日時を得るには、返されたオブジェクトの
<methodname>DateTimeImmutable::setTimezone</methodname> を呼び出してください。
</simpara>
</refsect1>

<refsect1 role="parameters">
Expand Down Expand Up @@ -67,6 +76,29 @@ echo $date->format('Y-m-d H:i:s.u');
<screen>
<![CDATA[
1970-01-01 00:02:03.456789
]]>
</screen>
</example>
<example xml:id="datetimeimmutable.createfromtimestamp.example.timezone">
<title>結果をデフォルトのタイムゾーンに変換する</title>
<programlisting role="php">
<![CDATA[
<?php
date_default_timezone_set('Europe/Amsterdam');

$date = DateTimeImmutable::createFromTimestamp(1700000000);
echo $date->format('Y-m-d H:i:s P e'), "\n";

$date = $date->setTimezone(new DateTimeZone(date_default_timezone_get()));
echo $date->format('Y-m-d H:i:s P e'), "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2023-11-14 22:13:20 +00:00 +00:00
2023-11-14 23:13:20 +01:00 Europe/Amsterdam
]]>
</screen>
</example>
Expand Down
35 changes: 34 additions & 1 deletion reference/datetime/datetimeimmutable/setisodate.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 726154e3c846bc0e16c60542377ea806df32e55d Maintainer: takagi Status: ready -->
<!-- EN-Revision: 506a93caec897989ad6e1d11a9fcbd53f5d8047b Maintainer: takagi Status: ready -->

<refentry xml:id="datetimeimmutable.setisodate" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -61,6 +61,39 @@
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされます。
たとえば、子クラスのコンストラクタが親クラスのコンストラクタを呼び出さない場合です。
</simpara>
</refsect1>

<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
オブジェクトが正しく初期化されていない場合、
<exceptionname>DateObjectError</exceptionname> がスローされるようになりました。
これより前のバージョンでは、<exceptionname>Error</exceptionname> がスローされていました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<example>
Expand Down
Loading