Skip to content

Commit fd4aaa8

Browse files
committed
Add Duration Arithmetic guideline
fixes #282
1 parent 137100e commit fd4aaa8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,21 @@ Avoid using negative numbers for the duration subject. Always prefer using a qua
16621662
5.hours.from_now
16631663
----
16641664

1665+
=== Duration Arithmetic
1666+
1667+
Use Duration methods instead of adding and subtracting with the current time.
1668+
1669+
[source,ruby]
1670+
----
1671+
# bad
1672+
Time.current - 1.minute
1673+
Time.zone.now + 2.days
1674+
1675+
# good
1676+
1.minute.ago
1677+
2.days.from_now
1678+
----
1679+
16651680
== Bundler
16661681

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

0 commit comments

Comments
 (0)