Example #1
0
def can_potentially_conflict(
    course_1_date_start, course_1_date_end, course_2_date_start, course_2_date_end
):
    """Checks two courses start & end dates to see whether they can overlap and
    hence potentially conflict. If any of the values are passed as None it will
    automatically consider that they can potentially conflict. Input type is
    string but has to be in a reasonable date format.

    Arguments:
        course_1_date_start {[string]} -- [course 1 start date in a reasonable date format]
        course_1_date_end {[string]} -- [course 1 end date in a reasonable date format]
        course_2_date_start {[string]} -- [course 2 start date in a reasonable date format]
        course_2_date_end {[string]} -- [course 2 end date in a reasonable date format]

    Returns:
        [bool] -- [True if if dates ranges of course 1 and 2 overlap, otherwise False]
    """
    potential_conflict_found = False
    course_1_date_start = short_date(course_1_date_start)
    course_1_date_end = short_date(course_1_date_end)
    course_2_date_start = short_date(course_2_date_start)
    course_2_date_end = short_date(course_2_date_end)
    if (
        course_1_date_start is None
        or course_1_date_end is None
        or course_2_date_start is None
        or course_2_date_end is None
    ):
        return True
    else:
        return (
            course_2_date_start <= course_1_date_end
            and course_2_date_end >= course_1_date_start
        )
Example #2
0
 def _resolve_date(self):
     dates = self._get('date')
     if 'dates' not in self:
         dates = {
             'start': short_date(self._get('date_start')),
             'end': short_date(self._get('date_end'))
         }
     return dates
Example #3
0
 def _resolve_date(self):
     dates = self._get("date")
     if "dates" not in self:
         dates = {
             "start": short_date(self._get("date_start")),
             "end": short_date(self._get("date_end")),
         }
     return dates