Skip to content

Commit 7912d72

Browse files
committed
fixup! Emphasize on past?/future?, move before?/after? to and info section below
1 parent 19197c0 commit 7912d72

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

README.adoc

+3-16
Original file line numberDiff line numberDiff line change
@@ -1808,22 +1808,9 @@ date.all_quarter
18081808
date.all_year
18091809
----
18101810

1811-
=== Comparison
1811+
=== Time Comparison
18121812

1813-
Avoid comparing time with `>` and `<` to avoid confusion.
1814-
1815-
[source,ruby]
1816-
----
1817-
# bad
1818-
created_at < 5.minutes.ago
1819-
shutdown_at > 1.minute.from_now
1820-
1821-
# good
1822-
created_at.before?(5.minutes.ago)
1823-
shutdown_at.after?(1.minute.from_now)
1824-
----
1825-
1826-
Use `past?` and `future?` when comparing with the current time.
1813+
Use `past?` and `future?` methods instead of comparing time to the current time.
18271814

18281815
[source,ruby]
18291816
----
@@ -1836,7 +1823,7 @@ grand_opening_at.past?
18361823
public_release_at.future?
18371824
----
18381825

1839-
NOTE: Rails 6.0 or later is required to use `before?` and `after?`.
1826+
NOTE: Rails 6.0 and later also provide `before?` and `after?` methods to compare two arbitrary time objects.
18401827

18411828
== Duration
18421829

0 commit comments

Comments
 (0)