Assuming you have a model setup for them, you can do something like this:
def currently_in_range(model)
now = DateTime.now
model.starttime < now && now < model.endtime
end
You should probably put it in a model class. Sort of:
class Thing < ActiveRecord::Base
...
def current?
now = DateTime.now
starttime < now && now < endtime
end
...
end
Then in your controller you can simply call model.current?
source
share