Skip to content

Commit

Permalink
Sync datetime functions (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Sep 6, 2024
1 parent 0b6c17c commit e576e95
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
10 changes: 5 additions & 5 deletions reference/datetime/datetimeinterface/diff.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: dbbcd32d72e4c9af14e9f3b940edbedfb54f965e Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 81908751c5787d433937a548235ca45fe3256841 Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<refentry xml:id="datetime.diff" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -121,8 +121,8 @@ echo $interval->format('%R%a days');
<![CDATA[
<?php
$originalTime = new DateTimeImmutable("2021-10-30 09:00:00 Europe/London");
$targedTime = new DateTimeImmutable("2021-10-31 08:30:00 Europe/London");
$interval = $originalTime->diff($targedTime);
$targetTime = new DateTimeImmutable("2021-10-31 08:30:00 Europe/London");
$interval = $originalTime->diff($targetTime);
echo $interval->format("%H:%I:%S (Full days: %a)"), "\n";
?>
]]>
Expand All @@ -146,8 +146,8 @@ echo $interval->format("%H:%I:%S (Full days: %a)"), "\n";
<![CDATA[
<?php
$originalTime = new DateTimeImmutable("2023-01-01 UTC");
$targedTime = new DateTimeImmutable("2023-12-31 UTC");
$interval = $originalTime->diff($targedTime);
$targetTime = new DateTimeImmutable("2023-12-31 UTC");
$interval = $originalTime->diff($targetTime);
echo "Full days: ", $interval->format("%a"), "\n";
?>
]]>
Expand Down
7 changes: 4 additions & 3 deletions reference/datetime/functions/date.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 7f385d3239d0df073e2208fb0c3c243ef13553bb Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: d94400847cec608f93830aa85e0761b97d7cb9bf Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.date" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>date</refname>
Expand Down Expand Up @@ -39,7 +39,8 @@
<note>
<simpara>
<function>date</function> 将始终生成 <literal>000000</literal> 作为微秒,因为它采用 <type>int</type>
参数,而如果 <classname>DateTime</classname> 是用微秒创建的,则 <methodname>DateTime::format</methodname> 支持微秒。
参数,而如果 <classname>DateTimeInterface</classname> 类型的对象是用微秒创建的,
则 <methodname>DateTimeInterface::format</methodname> 支持微秒。
</simpara>
</note>
</listitem>
Expand Down
9 changes: 6 additions & 3 deletions reference/datetime/functions/mktime.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: 57e27d2a7615da2ee6de57ed27eb40b473d487cb Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 349e3c6502e0bbeb15aef2b4a4a25f3f5e10fbfe Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.mktime" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -195,10 +195,13 @@ echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 98));
<programlisting role="php">
<![CDATA[
<?php
$lastday = mktime(0, 0, 0, 3, 0, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
echo 'Last day in Feb 2000 is: ', date('d', $lastday);
$lastday = mktime(0, 0, 0, 4, -31, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
echo 'Last day in Feb 2000 is: ', date('d', $lastday);
?>
]]>
</programlisting>
Expand Down
26 changes: 14 additions & 12 deletions reference/datetime/functions/strftime.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 5c951013ca04161992efed8b86fb40f55669958e Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: b93836ce6f7350932d11e784b793065fd2598e50 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.strftime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>strftime</refname>
Expand Down Expand Up @@ -516,7 +516,8 @@ echo strftime($format);
<programlisting role="php">
<![CDATA[
<?php
// Describe the formats.
// Describe the formats
$strftimeFormats = array(
'A' => 'A full textual representation of the day',
'B' => 'Full month name, based on the locale',
Expand Down Expand Up @@ -573,28 +574,29 @@ $strftimeFormats = array(
'%' => 'A literal percentage character ("%")',
);
// Results.
// Results
$strftimeValues = array();
// Evaluate the formats whilst suppressing any errors.
foreach($strftimeFormats as $format => $description){
if (False !== ($value = @strftime("%{$format}"))){
// Evaluate the formats whilst suppressing any errors
foreach ($strftimeFormats as $format => $description) {
if (false !== ($value = @strftime("%{$format}"))) {
$strftimeValues[$format] = $value;
}
}
// Find the longest value.
// Find the longest value
$maxValueLength = 2 + max(array_map('strlen', $strftimeValues));
// Report known formats.
foreach($strftimeValues as $format => $value){
// Report known formats
foreach ($strftimeValues as $format => $value) {
echo "Known format : '{$format}' = ", str_pad("'{$value}'", $maxValueLength), " ( {$strftimeFormats[$format]} )\n";
}
// Report unknown formats.
foreach(array_diff_key($strftimeFormats, $strftimeValues) as $format => $description){
// Report unknown formats
foreach (array_diff_key($strftimeFormats, $strftimeValues) as $format => $description) {
echo "Unknown format : '{$format}' ", str_pad(' ', $maxValueLength), ($description ? " ( {$description} )" : ''), "\n";
}
?>
]]>
</programlisting>
Expand Down
6 changes: 3 additions & 3 deletions reference/errorfunc/functions/trigger-error.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: d715365c098db000eaf7dcd987ee6093f6e83091 Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 210d382b5b139444fe2e16a5a3211076a65ff2ba Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.trigger-error" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>trigger_error</refname>
Expand Down Expand Up @@ -39,7 +39,7 @@
<term><parameter>error_level</parameter></term>
<listitem>
<para>
该 error 所特定的错误类型。仅 E_USER 系列常量对其有效,默认是 <constant>E_USER_NOTICE</constant>。
该 error 所特定的错误类型。仅 <constant>E_USER_<replaceable>*</replaceable></constant> 系列常量对其有效,默认是 <constant>E_USER_NOTICE</constant>。
</para>
</listitem>
</varlistentry>
Expand Down

0 comments on commit e576e95

Please sign in to comment.