Giter Club home page Giter Club logo

Comments (3)

kvps avatar kvps commented on June 10, 2024

Is there a way to handle this with current code? I am having the same situation.
Thanks!!!

from django-swingtime.

rfj001 avatar rfj001 commented on June 10, 2024

Here's what I am doing... I cloned the repo and modified the source directly to add a method to the OccurrenceManager class, but you could just write a function that takes two occurrences, or subclass occurrence.

def occurrence_at_time_exists(self, start, end, occurrence_set=None):
        if not occurrence_set:
            occurrence_set = Occurrence.objects.all()
        occurrence_set.filter(start_time__lte=start, end_time__gte=start)
        overlaps = occurrence_set.filter(
            models.Q(start_time__lte=start, end_time__gt=start) |
            models.Q(start_time__gte=start, start_time__lt=end) |
            models.Q(start_time=start, end_time=end)
        ).exists()
        return overlaps

Note that this implementation returns False if one occurrence begins at the same time that the other ends. For example, if I have an occurrence from 9:00-10:00 and another from 10:00-11:00 this would not interpret them as overlapping.

from django-swingtime.

kvps avatar kvps commented on June 10, 2024

Thanks. I am working more modifications on swingtime code, this really helps. Thanks again!!!

from django-swingtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.