From 1476c8a419a0cdcd5cd9de1412c57fd3f958abe9 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sat, 27 Jul 2024 00:41:32 +0300 Subject: [PATCH 1/2] Add the time comparison guideline --- README.adoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.adoc b/README.adoc index 47652a5..ba711a2 100644 --- a/README.adoc +++ b/README.adoc @@ -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 From 8dd3aa052f01c0d9f4fca78774d3bfb46963b7a9 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sat, 2 Aug 2025 08:59:49 +0300 Subject: [PATCH 2/2] Remove Rails version mention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s available all supported version --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index ba711a2..0f61745 100644 --- a/README.adoc +++ b/README.adoc @@ -1823,7 +1823,7 @@ 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. +NOTE: `before?` and `after?` methods can compare two arbitrary time objects. == Duration