Working with days which don't start at midnight

128 views Asked by At

I'm working on an application where I have a schedule where first item start at 5am and the last item ends at 3am of the next day, but I need to treat it as if it's the same day.

I know it will involve a lot of custom date queries on my models, but I'd like to know if there's a good approach I can do in Rails, to handle this "hour shift"

Somewhat related questions I found before posting:

1

There are 1 answers

0
Triveni Badgujar On

You can use following date range while querying.

Between DateTime.now.midnight + 3.days + 5.hours and DateTime.now.midnight + 4.days + 5.hours

Here, you can use (n-1).days to n.days

Hope this is useful