Skip to content

Commit

Permalink
Add the time comparison guideline
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Jul 29, 2024
1 parent 524a1ac commit 1476c8a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,23 @@ date.all_quarter
date.all_year
----

=== Time Comparison

Use `past?` and `future?` methods instead of comparing time to the current time.

[source,ruby]
----
# bad
grand_opening_at < Time.current
public_release_at > Time.current
# good
grand_opening_at.past?
public_release_at.future?
----

NOTE: Rails 6.0 and later also provide `before?` and `after?` methods to compare two arbitrary time objects.

== Duration

=== Duration Application
Expand Down

0 comments on commit 1476c8a

Please sign in to comment.