Example #1
0
def check_slot_available(time,booklist):
    max_slot = 2
    if time.weekday() == 5:
        max_slot = 4
    
    count = booklist.count(time)
    return max_slot - count 
Example #2
0
def getClassInfoFromTime(time: datetime, group_id, classnums=None) -> list:
    if classnums is None:
        classnums = [1, 2, 3, 4, 5]

    weekday = time.weekday()
    week = get_session_week(time)
    return getClassInfo(week, weekday, group_id, classnums)
Example #3
0
    def target_datetime(self):
        time = utilities.TestableDateTime.now()
        next_day = self.next_day
        this_day = utilities.convert_datetime_weekday_to_zero_sunday(time.weekday())

        target = time
        days_delta = utilities.convert_days_flag_to_weekday(next_day) - this_day
        if days_delta == 0:
            # this means the alarm is set weekly, and it is that day, bump it a week if it has passed today
            days_delta += 7 if self.alarm_passed_today else 0
        elif days_delta < 0:
            days_delta += (
                7  # the day of the week has passed, delta should be positive to the next occurrence
            )

        target += timedelta(days=days_delta)
        target = target.replace(
            hour=self.target_hour, minute=self.target_minute
        )  # returns new target time

        return target
Example #4
0
 def index(time):
     day = 60 * 24
     hour = 60
     return time.weekday() * day +  time.hour * hour + time.minute
Example #5
0
 def ciclo_semanal_continente(self, time):
     # From http://www.erse.pt/pt/electricidade/tarifaseprecos/periodoshorarios/Paginas/CicloSemanalTodosFornecPtCont.aspx
     if self.is_summer(time):
         # VerĂ£o
         if 0 <= time.weekday() < 5:
             # Seg a Sex
             if self.in_time_range(9, 15, time, 12, 15):
                 return self.PONTA
             if self.in_time_range(7, 0, time, 9, 15) or self.in_time_range(
                     12, 15, time, 0, 0):
                 return self.CHEIAS
             if self.in_time_range(0, 0, time, 2, 0) or self.in_time_range(
                     6, 0, time, 7, 0):
                 return self.VAZIO_NORMAL
             if self.in_time_range(2, 0, time, 6, 0):
                 return self.SUPER_VAZIO
         if time.weekday() == 5:
             # Sabado
             if self.in_time_range(9, 0, time, 14, 0) or self.in_time_range(
                     20, 0, time, 22, 0):
                 return self.CHEIAS
             if (self.in_time_range(0, 0, time, 2, 0)
                     or self.in_time_range(6, 0, time, 9, 0)
                     or self.in_time_range(14, 0, time, 20, 0)
                     or self.in_time_range(22, 0, time, 0, 0)):
                 return self.VAZIO_NORMAL
             if self.in_time_range(2, 0, time, 6, 0):
                 return self.SUPER_VAZIO
         if time.weekday() == 6:
             # Domingo
             if self.in_time_range(0, 0, time, 2, 0) or self.in_time_range(
                     6, 0, time, 0, 0):
                 return self.VAZIO_NORMAL
             if self.in_time_range(2, 0, time, 6, 0):
                 return self.SUPER_VAZIO
     else:
         # Inverno
         if 0 <= time.weekday() < 5:
             # Seg a Sex
             if self.in_time_range(9, 30, time, 12,
                                   00) or self.in_time_range(
                                       18, 30, time, 21, 0):
                 return self.PONTA
             if (self.in_time_range(7, 0, time, 9, 30)
                     or self.in_time_range(12, 0, time, 18, 30)
                     or self.in_time_range(21, 0, time, 0, 0)):
                 return self.CHEIAS
             if self.in_time_range(0, 0, time, 2, 0) or self.in_time_range(
                     6, 0, time, 7, 0):
                 return self.VAZIO_NORMAL
             if self.in_time_range(2, 0, time, 6, 0):
                 return self.SUPER_VAZIO
         if time.weekday() == 5:
             # Sabado
             if self.in_time_range(9, 30, time, 13,
                                   0) or self.in_time_range(
                                       18, 30, time, 22, 0):
                 return self.CHEIAS
             if (self.in_time_range(0, 0, time, 2, 0)
                     or self.in_time_range(6, 0, time, 9, 30)
                     or self.in_time_range(13, 0, time, 18, 30)
                     or self.in_time_range(22, 0, time, 0, 0)):
                 return self.VAZIO_NORMAL
             if self.in_time_range(2, 0, time, 6, 0):
                 return self.SUPER_VAZIO
         if time.weekday() == 6:
             # Domingo
             if self.in_time_range(0, 0, time, 2, 0) or self.in_time_range(
                     6, 0, time, 0, 0):
                 return self.VAZIO_NORMAL
             if self.in_time_range(2, 0, time, 6, 0):
                 return self.SUPER_VAZIO
Example #6
0
 def find(self, time):
     return self.schedule[time.weekday()+1].find(time)
Example #7
0
 def getNext(self, time):
     return self.schedule[time.weekday()+1].getNext(time.hour, time.minute)
Example #8
0
 def find(self, time):
     return self.schedule[time.weekday() + 1].find(time)
Example #9
0
 def getNext(self, time):
     return self.schedule[time.weekday() + 1].getNext(
         time.hour, time.minute)