def daylight_saving_valid(self): """Determines whether or not the match is valid during all weeks of the schedule. Even though the match will definitely be valid on earliest_course_start_UTC, it is possible that the student or tutor will no longer be able to make the course if daylight saving occurs for the student or for the tutor as the course progresses. Also, some of the scheduled datetimes may be non-existent or ambiguous because of daylight saving. Returns: A boolean whether or not both the student and the tutor can make all courses in their respective schedules. """ # Check that the student schedule is valid for student_dt in self.student_course_schedule: student_wt = WeeklyTime.from_datetime(student_dt) index = Availability.SLOT_START_TIME_TO_INDEX[student_wt] if not self.student.availability.free_course_slots[index]: return False # Check that all minutes of the class are valid naive_student_dt = student_dt.replace(tzinfo=None) for i in range(Availability.MINUTES_PER_COURSE): dt = naive_student_dt + timedelta(minutes=i) if not util.naive_dt_is_valid(dt, self.student.tz_str): return False # Check that the tutor schedule is valid for tutor_dt in self.tutor_course_schedule: tutor_wt = WeeklyTime.from_datetime(tutor_dt) index = Availability.SLOT_START_TIME_TO_INDEX[tutor_wt] if not self.tutor.availability.free_course_slots[index]: return False # Check that all minutes of the class are valid naive_tutor_dt = tutor_dt.replace(tzinfo=None) for i in range(Availability.MINUTES_PER_COURSE): dt = naive_tutor_dt + timedelta(minutes=i) if not util.naive_dt_is_valid(dt, self.tutor.tz_str): return False return True
def test_from_datetime_2001_09_10(self): self.assertEqual(WeeklyTime.from_datetime(c.dt_2001_09_10), c.monday_0000)
def test_from_datetime_2017_01_29_0059(self): self.assertEqual(WeeklyTime.from_datetime(c.dt_2017_01_29_0059), c.sunday_0059)