Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:25:31+00:00 2026-05-26T10:25:31+00:00

I need to implement is open now filter for my website that lists venues,

  • 0

I need to implement “is open now” filter for my website that lists venues, but I don’t know where to start. My website is implemented using Python, webpy, MySQL database.

I have to store the opening hours for every venue and select venues that are open now.

An example of opening hours: “Works from 9:30am to 11pm on weekdays, 11am to 11pm on weekend”, or “Works round the clock excluding 6am to 7am”.

Opening hours may be different for every day of week, day can have more than one interval of time, and I need to hack in exceptions for specific holidays.

Any tips/suggestions on the interface, data schema and query are welcome.

UPD: I have managed to come up with this solution, is it ok?

from dateutil.relativedelta import *
from dateutil.rrule import *
from datetime import *
from date import *

# venue can have many rules
hours_start = 23
minutes_start = 30
hours_end = 13  # if time_end is less than time_start then it ends next day
minutes_end = 30
days_of_week = (TH)

hours_diff = hours_end - hours_start
minutes_diff = minutes_end - minutes_start

if hours_diff < 0 or hours_diff == 0 and minutes_diff < 0:
    hours_diff += 24

datetime_start = date.today() + relativedelta(hours=+hours_start, minutes=+minutes_start, days=-1) # Yesterday time_start
now = datetime.now()
occurrence = rrule(WEEKLY, wkst=MO, byweekday=days_of_week, dtstart=datetime_start).before(now, True)

if now <= occurrence + relativedelta(hours=hours_diff, minutes=minutes_diff):
    print "IS OPEN NOW"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:25:31+00:00Added an answer on May 26, 2026 at 10:25 am

    I’ve used an app called django-schedule which has some similar features.

    If you dig in to the source, you’ll see it uses python-dateutil (see rrules) underneath. It keeps a list of schedule rules for each event in the database.

    You could use a similar tactic. When venue-open-status is queried see if the current datetime fits inside the start/end of an occurrence provided by the venue’s schedule rules. If so, it is open.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement a simple probe that uses open microsoft rdp protocol. But
I've developed application using Silverlight, and now I need to implement printing, I've used
I'm working on an open source project (Logbus-ng), and I need to implement a
I'm working on an academic open source project and now I need to create
I need to implement a Diff algorithm in VB.NET to find the changes between
I need to implement version control, even for just the developing I do at
I need to implement a 4-to-1 function in Veriog. The input is 4 bits,
I need to implement auto-capitalization inside of a Telerik RadEditor control on an ASPX
I need to implement an in-memory tuple-of-strings matching feature in C. There will be
We need to implement a simple state machine in C . Is a standard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.