From 79615699356490275a65235cbb7831ea863b8631 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 26 Mar 2024 09:05:51 +0900 Subject: [PATCH 1/2] docs: add empty line --- user_guide_src/source/libraries/time.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/time.rst b/user_guide_src/source/libraries/time.rst index 668a7bebbe7c..c58755736e11 100644 --- a/user_guide_src/source/libraries/time.rst +++ b/user_guide_src/source/libraries/time.rst @@ -366,7 +366,9 @@ Viewing Differences =================== To compare two Times directly, you would use the ``difference()`` method, which returns a ``CodeIgniter\I18n\TimeDifference`` -instance. The first parameter is either a Time instance, a DateTime instance, or a string with the date/time. If +instance. + +The first parameter is either a Time instance, a DateTime instance, or a string with the date/time. If a string is passed in the first parameter, the second parameter can be a timezone string: .. literalinclude:: time/038.php From 4e559763a05f62edd797b48363928ff484d92da6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 26 Mar 2024 09:19:18 +0900 Subject: [PATCH 2/2] docs: add note for DST and Time::difference() --- user_guide_src/source/libraries/time.rst | 6 ++++++ user_guide_src/source/libraries/time/042.php | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 user_guide_src/source/libraries/time/042.php diff --git a/user_guide_src/source/libraries/time.rst b/user_guide_src/source/libraries/time.rst index c58755736e11..ee0f0aa0c5c6 100644 --- a/user_guide_src/source/libraries/time.rst +++ b/user_guide_src/source/libraries/time.rst @@ -379,6 +379,12 @@ the original time: .. literalinclude:: time/039.php +.. note:: When calculating the difference in the number of days, unexpected results + may be returned if a day is not 24 hours long due to Daylight Saving Time + (DST). + + .. literalinclude:: time/042.php + You can use either ``getX()`` methods, or access the calculate values as if they were properties: .. literalinclude:: time/040.php diff --git a/user_guide_src/source/libraries/time/042.php b/user_guide_src/source/libraries/time/042.php new file mode 100644 index 000000000000..c5b521f75277 --- /dev/null +++ b/user_guide_src/source/libraries/time/042.php @@ -0,0 +1,10 @@ +difference($test); + +echo $diff->getDays(); // 0