How to know if today's date is in a date range?

前端 未结 8 1704
死守一世寂寞
死守一世寂寞 2020-12-12 10:14

I have an event with start_time and end_time and want to check if the event is \"in progress\". That would be to check if today\'s date is in the r

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 11:12

    If they're timestamps:

    def in_progress?
      (start_time..end_time).include?(Time.now)
    end

提交回复
热议问题