Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jul 27, 2024
1 parent 970f3b9 commit 4e892ef
Showing 7 changed files with 76 additions and 0 deletions.
6 changes: 6 additions & 0 deletions user_guide_src/source/changelogs/v4.6.0.rst
Original file line number Diff line number Diff line change
@@ -52,6 +52,12 @@ with different arguments in before or after. See

.. _v460-interface-changes:

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.

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

27 changes: 27 additions & 0 deletions user_guide_src/source/installation/upgrade_460.rst
Original file line number Diff line number Diff line change
@@ -29,6 +29,33 @@ See :ref:`ChangeLog <v460-behavior-changes-exceptions>` for details.

If you have code that catches these exceptions, change the exception classes.

.. _upgrade-460-time-keeps-microseconds:

Time keeps Microseconds
=======================

In previous versions, some methods in :doc:`Time <../libraries/time>` lost microseconds.
But the bugs have been fixed.

.. literalinclude:: upgrade_460/002.php
:lines: 2-

.. literalinclude:: upgrade_460/003.php
:lines: 2-

.. literalinclude:: upgrade_460/006.php
:lines: 2-

Note that ``Time`` with the current time has been holding microseconds since before.

.. literalinclude:: upgrade_460/004.php
:lines: 2-

And methods that returns ``int`` still lose the microseconds.

.. literalinclude:: upgrade_460/005.php
:lines: 2-

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

8 changes: 8 additions & 0 deletions user_guide_src/source/installation/upgrade_460/002.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use CodeIgniter\I18n\Time;

$time = Time::createFromFormat('Y-m-d H:i:s.u', '2024-07-09 09:13:34.654321');
echo $time->format('Y-m-d H:i:s.u');
// Before: 2024-07-09 09:13:34.000000
// After: 2024-07-09 09:13:34.654321
8 changes: 8 additions & 0 deletions user_guide_src/source/installation/upgrade_460/003.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use CodeIgniter\I18n\Time;

$time = new Time('1 hour ago');
echo $time->format('Y-m-d H:i:s.u');
// Before: 2024-07-26 21:05:57.000000
// After: 2024-07-26 21:05:57.857235
8 changes: 8 additions & 0 deletions user_guide_src/source/installation/upgrade_460/004.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use CodeIgniter\I18n\Time;

$time = Time::now();
echo $time->format('Y-m-d H:i:s.u');
// Before: 2024-07-26 21:39:32.249072
// After: 2024-07-26 21:39:32.249072
9 changes: 9 additions & 0 deletions user_guide_src/source/installation/upgrade_460/005.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use CodeIgniter\I18n\Time;

$time1 = new Time('2024-01-01 12:00:00');
echo $time1->getTimestamp(); // 1704110400

$time2 = new Time('2024-01-01 12:00:00.654321');
echo $time2->getTimestamp(); // 1704110400
10 changes: 10 additions & 0 deletions user_guide_src/source/installation/upgrade_460/006.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

use CodeIgniter\I18n\Time;

$time1 = new Time('2024-01-01 12:00:00.654321');
$time2 = new Time('2024-01-01 12:00:00');

$time1->equals($time2);
// Before: true
// After: false

0 comments on commit 4e892ef

Please sign in to comment.