Best way to express "less than an hour in the future" in Rails?
ruby, ruby-on-rails, time
Solution
You could use `from_now`:
if t[from_station] < 1.hour.from_now
When using `Time.zone.now`, you'll have to specify it, so `since` is probably more readable (`from_now` is just an alias to `since`):
if t[from_station] < 1.hour.since(Time.zone.now)
Problem
If a train leaves less than an hour from now, I want its row in the schedule table to be highlighted red. Currently I'm doing the calculation like this: ``` if Time.zone.now + 1.hour > t[from_station] # do whatever end ``` This works and kind of makes sense, but I wonder if there's a clearer / more idiomatic way to express this (I could imagine coming back to this code in a few months and having to pause for a moment to mentally parse `Time.zone.now + 1.hour`).