From 3b51c3e5c53b01778c1df013a7db19b15e027244 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 6 Aug 2024 09:53:27 +0900 Subject: [PATCH] docs: add docs --- user_guide_src/source/changelogs/v4.6.0.rst | 10 +++++++++- .../source/installation/upgrade_460.rst | 20 +++++++++++++++++++ user_guide_src/source/libraries/time.rst | 6 ++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.6.0.rst b/user_guide_src/source/changelogs/v4.6.0.rst index 1cd78a3d51e2..d4cd6b3ae606 100644 --- a/user_guide_src/source/changelogs/v4.6.0.rst +++ b/user_guide_src/source/changelogs/v4.6.0.rst @@ -57,7 +57,13 @@ Added check to prevent Auto-Discovery of Registrars from running twice. If it is executed twice, an exception will be thrown. See :ref:`upgrade-460-registrars-with-dirty-hack`. -.. _v460-interface-changes: +Time::createFromTimestamp() +--------------------------- + +``Time::createFromTimestamp()`` handles timezones differently. If ``$timezone`` +is not explicitly passed then the instance has timezone set to UTC unlike earlier +where the currently set default timezone was used. +See :ref:`Upgrading Guide ` for details. Time with Microseconds ---------------------- @@ -65,6 +71,8 @@ Time with Microseconds Fixed bugs that some methods in ``Time`` to lose microseconds have been fixed. See :ref:`Upgrading Guide ` for details. +.. _v460-interface-changes: + Interface Changes ================= diff --git a/user_guide_src/source/installation/upgrade_460.rst b/user_guide_src/source/installation/upgrade_460.rst index 7078110b7068..5cbfd664bf92 100644 --- a/user_guide_src/source/installation/upgrade_460.rst +++ b/user_guide_src/source/installation/upgrade_460.rst @@ -29,6 +29,26 @@ See :ref:`ChangeLog ` for details. If you have code that catches these exceptions, change the exception classes. +.. _upgrade-460-time-create-from-timestamp: + +Time::createFromTimestamp() Timezone Change +=========================================== + +When you do not explicitly pass a timezone, now +:ref:`Time::createFromTimestamp() ` returns a Time +instance with **UTC**. In v4.4.6 to prior to v4.6.0, a Time instance with the +currently set default timezone was returned. + +This behavior change normalizes behavior with changes in PHP 8.4 which adds a +new ``DateTimeInterface::createFromTimestamp()`` method. + +If you want to keep the default timezone, you need to pass the timezone as the +second parameter:: + + use CodeIgniter\I18n\Time; + + $time = Time::createFromTimestamp(1501821586, date_default_timezone_get()); + .. _upgrade-460-time-keeps-microseconds: Time keeps Microseconds diff --git a/user_guide_src/source/libraries/time.rst b/user_guide_src/source/libraries/time.rst index b18e56350403..ccc008f5c533 100644 --- a/user_guide_src/source/libraries/time.rst +++ b/user_guide_src/source/libraries/time.rst @@ -126,8 +126,10 @@ This method takes a UNIX timestamp and, optionally, the timezone and locale, to .. literalinclude:: time/012.php -.. note:: Due to a bug, prior to v4.4.6, this method returned a Time instance - in timezone UTC when you do not specify a timezone. +If you do not explicitly pass a timezone, it returns a Time instance with **UTC**. + +.. note:: In v4.4.6 to prior to v4.6.0, this method returned a Time instance + with the default timezone when you do not specify a timezone. createFromInstance() ====================