Skip to content

Commit 025e227

Browse files
authored
In durations, Don't use .since without a parameter, prefer .from_now.
1 parent aaac037 commit 025e227

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,24 @@ Time.zone.now # => Fri, 12 Mar 2014 22:04:47 EET +02:00
15331533
Time.current # Same thing but shorter.
15341534
----
15351535

1536+
== Duration
1537+
1538+
=== `.since` [[duration-since]]
1539+
1540+
Don't use `.since` without a parameter, prefer `.from_now`.
1541+
1542+
[source,ruby]
1543+
----
1544+
# bad
1545+
5.hours.since # => It's not clear at first sight that `since` refers to "since now"
1546+
1547+
# good
1548+
5.hours.from_now # when refering a future time from now, use from_now
1549+
1550+
yesterday = 1.day.ago
1551+
tomorrow = 2.days.since(yesterday) # use since only when you have a referential Time in the past
1552+
----
1553+
15361554
== Bundler
15371555

15381556
=== Dev/Test Gems [[dev-test-gems]]

0 commit comments

Comments
 (0)