diff --git a/pyerse/ciclos.py b/pyerse/ciclos.py index e9a3dd9..4de6051 100644 --- a/pyerse/ciclos.py +++ b/pyerse/ciclos.py @@ -87,7 +87,7 @@ def get_periodo_horario(cls, time): # Inverno if 0 <= time.weekday() < 5: # Seg a Sex - if cls.in_time_range(9, 30, time, 12, 00) or cls.in_time_range( + if cls.in_time_range(9, 30, time, 12, 0) or cls.in_time_range( 18, 30, time, 21, 0 ): return ph.PONTA @@ -138,7 +138,7 @@ def __str__(self) -> str: def get_periodo_horario(cls, time): if cls.is_summer(time): # Verão - if cls.in_time_range(10, 30, time, 13, 00) or cls.in_time_range( + if cls.in_time_range(10, 30, time, 13, 0) or cls.in_time_range( 19, 30, time, 21, 0 ): return ph.PONTA @@ -176,6 +176,67 @@ def get_periodo_horario(cls, time): return ph.VAZIO_NORMAL if cls.in_time_range(2, 0, time, 6, 0): return ph.SUPER_VAZIO + + class Ciclo_Semanal_Acores(Ciclo): + """Ciclo semanal Açores (os períodos horários diferem entre dias úteis e fim de semana).""" + def __str__(self) -> str: + return "Ciclo Semanal Açores" + + @classmethod + def get_periodo_horario(cls, time): + if cls.is_summer(time): + # Verão + if 0 <= time.weekday() < 5: + # Seg a Sex + if cls.in_time_range(10, 30, time, 15, 30): + return ph.PONTA + if cls.in_time_range(7, 0, time, 10, 30) or cls.in_time_range( + 15, 30, time, 0, 0 + ): + return ph.CHEIAS + if cls.in_time_range(0, 0, time, 7, 0): + return ph.VAZIO_NORMAL + if time.weekday() == 5: + # Sabado + if cls.in_time_range(11, 0, time, 14, 30) or cls.in_time_range( + 19, 30, time, 23, 0 + ): + return ph.CHEIAS + if ( + cls.in_time_range(23, 0, time, 11, 0): + return ph.VAZIO_NORMAL + if time.weekday() == 6: + # Domingo + if cls.in_time_range(0, 0, time, 0, 0): + return ph.VAZIO_NORMAL + else: + # Inverno + if 0 <= time.weekday() < 5: + # Seg a Sex + if cls.in_time_range(18, 30, time, 21, 30): + return ph.PONTA + if ( + cls.in_time_range(7, 0, time, 18, 30) + or cls.in_time_range(21, 30, time, 0, 0) + ): + return ph.CHEIAS + if cls.in_time_range(0, 0, time, 7, 0): + return ph.VAZIO_NORMAL + if time.weekday() == 5: + # Sabado + if cls.in_time_range(11, 30, time, 13, 0) or cls.in_time_range( + 18, 0, time, 23, 0 + ): + return ph.CHEIAS + if ( + cls.in_time_range(23, 0, time, 11, 30) + or cls.in_time_range(13, 30, time, 18, 0) + ): + return ph.VAZIO_NORMAL + if time.weekday() == 6: + # Domingo + if cls.in_time_range(0, 0, time, 0, 0): + return ph.VAZIO_NORMAL -MAPPING = {str(Ciclo_Semanal()): Ciclo_Semanal, str(Ciclo_Diario()): Ciclo_Diario} +MAPPING = {str(Ciclo_Semanal()): Ciclo_Semanal, str(Ciclo_Diario()): Ciclo_Diario, str(Ciclo_Semanal_Acores()): Ciclo_Semanal_Acores}