Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Aug 6, 2024
1 parent 410635c commit 4aa7a39
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
10 changes: 9 additions & 1 deletion user_guide_src/source/changelogs/v4.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,22 @@ 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 <upgrade-460-time-create-from-timestamp>` for details.

Time with Microseconds
----------------------

Fixed bugs that some methods in ``Time`` to lose microseconds have been fixed.
See :ref:`Upgrading Guide <upgrade-460-time-keeps-microseconds>` for details.

.. _v460-interface-changes:

Interface Changes
=================

Expand Down
20 changes: 20 additions & 0 deletions user_guide_src/source/installation/upgrade_460.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ See :ref:`ChangeLog <v460-behavior-changes-exceptions>` 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() <time-createfromtimestamp>` returns a Time
instance with **UTC** is returned. 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
Expand Down
6 changes: 4 additions & 2 deletions user_guide_src/source/libraries/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()
====================
Expand Down

0 comments on commit 4aa7a39

Please sign in to comment.