Skip to content

Commit b1e2366

Browse files
authored
Merge pull request #8884 from obozdag/patch-2
docs: Some small typos and modifications in libraries/time.rst
2 parents b999381 + 2e480d5 commit b1e2366

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

user_guide_src/source/libraries/time.rst

+31-29
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Times and Dates
33
###############
44

5-
CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTimeImmutable object, but uses the Intl
5+
CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTimeImmutable class, but uses the Intl
66
extension's features to convert times across timezones and display the output correctly for different locales. This class
77
is the ``Time`` class and lives in the ``CodeIgniter\I18n`` namespace.
88

@@ -34,9 +34,9 @@ This can be any string that PHP's `DateTimeImmutable`_ constructor can parse. Se
3434

3535
.. literalinclude:: time/001.php
3636

37-
You can pass in strings representing the timezone and the locale in the second and parameters, respectively. Timezones
38-
can be any supported by PHP's `DateTimeZone <https://www.php.net/manual/en/timezones.php>`__ class. The locale can be
39-
any supported by PHP's `Locale <https://www.php.net/manual/en/class.locale.php>`__ class. If no locale or timezone is
37+
You can pass in strings representing the timezone and the locale in the second and the third parameters, respectively. The timezone
38+
can be any one supported by PHP's `DateTimeZone <https://www.php.net/manual/en/timezones.php>`__ class. The locale can be
39+
any one supported by PHP's `Locale <https://www.php.net/manual/en/class.locale.php>`__ class. If no locale or timezone is
4040
provided, the application defaults will be used.
4141

4242
.. literalinclude:: time/002.php
@@ -45,8 +45,8 @@ now()
4545
=====
4646

4747
The Time class has several helper methods to instantiate the class. The first of these is the ``now()`` method
48-
that returns a new instance set to the current time. You can pass in strings representing the timezone and the locale
49-
in the second and parameters, respectively. If no locale or timezone is provided, the application defaults will be used.
48+
that returns a new instance set to the current time. You can pass in strings representing the timezone and locale
49+
in the second and third parameters, respectively. If no locale or timezone is provided, the application defaults will be used.
5050

5151
.. literalinclude:: time/003.php
5252

@@ -86,15 +86,15 @@ createFromDate()
8686
================
8787

8888
Given separate inputs for **year**, **month**, and **day**, will return a new instance. If any of these parameters
89-
are not provided, it will use the current value to fill it in. Accepts strings for the timezone and locale in the
89+
are not provided, it will use the current year, month and day. Accepts strings for the timezone and locale in the
9090
fourth and fifth parameters:
9191

9292
.. literalinclude:: time/008.php
9393

9494
createFromTime()
9595
================
9696

97-
Like ``createFromDate()`` except it is only concerned with the **hours**, **minutes**, and **seconds**. Uses the
97+
Like ``createFromDate()``, except it is only concerned with the **hours**, **minutes**, and **seconds**. Uses the
9898
current day for the date portion of the Time instance. Accepts strings for the timezone and locale in the
9999
fourth and fifth parameters:
100100

@@ -104,7 +104,7 @@ create()
104104
========
105105

106106
A combination of the previous two methods, takes **year**, **month**, **day**, **hour**, **minutes**, and **seconds**
107-
as separate parameters. Any value not provided will use the current date and time to determine. Accepts strings for the
107+
as separate parameters. Any value not provided will use the current date and time. Accepts strings for the
108108
timezone and locale in the fourth and fifth parameters:
109109

110110
.. literalinclude:: time/010.php
@@ -178,21 +178,21 @@ This will return a localized version of string formatted as (``Y-m-d H:i:s``):
178178
toDateString()
179179
==============
180180

181-
Displays just the localized version of date portion of the Time:
181+
Displays just the localized date portion of the Time:
182182

183183
.. literalinclude:: time/017.php
184184

185185
toTimeString()
186186
==============
187187

188-
Displays just the localized version of time portion of the value:
188+
Displays just the localized time portion of the value:
189189

190190
.. literalinclude:: time/018.php
191191

192192
humanize()
193193
==========
194194

195-
This methods returns a string that displays the difference between the current date/time and the instance in a
195+
This method returns a string that displays the difference between the current date/time and the instance in a
196196
human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
197197
'in 1 month', etc:
198198

@@ -203,17 +203,18 @@ The exact time displayed is determined in the following manner:
203203
=============================== =================================
204204
Time difference Result
205205
=============================== =================================
206-
$time > 1 year && < 2 years in 1 year / 1 year ago
207-
$time > 1 month && < 1 year in 6 months / 6 months ago
208-
$time > 7 days && < 1 month in 3 weeks / 3 weeks ago
209-
$time > today && < 7 days in 4 days / 4 days ago
210-
$time == tomorrow / yesterday Tomorrow / Yesterday
211-
$time > 59 minutes && < 1 day in 2 hours / 2 hours ago
212-
$time > now && < 1 hour in 35 minutes / 35 minutes ago
206+
1 year < $time < 2 years in 1 year / 1 year ago
207+
1 month < $time < 1 year in 6 months / 6 months ago
208+
7 days < $time < 1 month in 3 weeks / 3 weeks ago
209+
today < $time < 7 days in 4 days / 4 days ago
210+
$time == yesterday / tomorrow Yesterday / Tomorrow
211+
59 minutes < $time < 1 day in 2 hours / 2 hours ago
212+
now < $time < 1 hour in 35 minutes / 35 minutes ago
213213
$time == now Now
214214
=============================== =================================
215215

216-
The exact language used is controlled through the language file, **Time.php**.
216+
The result strings are coming from the language file, **system/Language/en/Time.php**.
217+
If you want to overwrite them, create **app/Language/{locale}/Time.php**.
217218

218219
******************************
219220
Working with Individual Values
@@ -240,7 +241,7 @@ In addition to these, a number of methods exist to provide additional informatio
240241
getAge()
241242
--------
242243

243-
Returns the age, in years, of between the Time's instance and the current time. Perfect for checking
244+
Returns the age, in years, between the Time instance and the current time. Perfect for checking
244245
the age of someone based on their birthday:
245246

246247
.. literalinclude:: time/022.php
@@ -402,7 +403,7 @@ humanize()
402403

403404
Much like Time's ``humanize()`` method, this returns a string that displays the difference between the times in a
404405
human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
405-
'in 1 month', etc. The biggest differences are in how very recent dates are handled:
406+
'in 1 month', etc. The biggest difference is in how very recent dates are handled:
406407

407408
.. literalinclude:: time/041.php
408409

@@ -411,13 +412,14 @@ The exact time displayed is determined in the following manner:
411412
=============================== =================================
412413
Time difference Result
413414
=============================== =================================
414-
$time > 1 year && < 2 years in 1 year / 1 year ago
415-
$time > 1 month && < 1 year in 6 months / 6 months ago
416-
$time > 7 days && < 1 month in 3 weeks / 3 weeks ago
417-
$time > today && < 7 days in 4 days / 4 days ago
418-
$time > 1 hour && < 1 day in 8 hours / 8 hours ago
419-
$time > 1 minute && < 1 hour in 35 minutes / 35 minutes ago
415+
1 year < $time < 2 years in 1 year / 1 year ago
416+
1 month < $time < 1 year in 6 months / 6 months ago
417+
7 days < $time < 1 month in 3 weeks / 3 weeks ago
418+
today < $time < 7 days in 4 days / 4 days ago
419+
1 hour < $time < 1 day in 8 hours / 8 hours ago
420+
1 minute < $time < 1 hour in 35 minutes / 35 minutes ago
420421
$time < 1 minute Now
421422
=============================== =================================
422423

423-
The exact language used is controlled through the language file, **Time.php**.
424+
The result strings are coming from the language file, **system/Language/en/Time.php**.
425+
If you want to overwrite them, create **app/Language/{locale}/Time.php**.

0 commit comments

Comments
 (0)