Restaurants Open Now Filter

Hi everyone,

I am building a restaurant search app where users can look for restaurants applying filters such as food category, location, etc.

There is one filter I’m challenged by, which is the “open now” property - created so that a user would be able to view only the restaurants that are open now.

Assuming we have the opening hours data arranged the way we like (say, “Restaurants” collection would have a relationship with “Opening Hours” collection, consisting of day of week, start time & end time)…

How would you create this filter?

*note: restaurants can have multiple opening periods during a certain day, e.g.: open on Sundays between 1PM-4PM and 8PM-12AM.

**would also appreciate any tip on how to create the “Opening Hours” table, extracting from the Google Places opening hours. API example,
Place Details  |  Places API  |  Google Developers (alternatively, I could do it manually).

Thank you a lot :pray:
-Amir

Hi @amir ,

You can try experiment with start of today, next to current time, put them inside the input field at initial, this would determine week of day.

For time, you need to compare current time fraction with timezone, if it is within the range of restaurant start time and end time. Remember to play in fraction, you can multiply them with 60 seconds to get minutes, multiply 60 minutes to get hours.

Search the forum regarding date time, check my Komun template (in resources category in this forum) to see get timezone calculated.

Playing with date and time requires persistence.

Thank you a lot @Yongki .
Very helpful!

/Amir

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.