Skip to content

Commit

Permalink
off_peak bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosalmi committed Feb 1, 2025
1 parent 1a221bb commit d2db7c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lxc_autoscale/scaling_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,10 @@ def is_off_peak() -> bool:
True if it is off-peak, otherwise False.
"""
current_hour = datetime.now().hour
logging.debug(f"Current hour: {current_hour}, Off-peak hours: {DEFAULTS['off_peak_start']} - {DEFAULTS['off_peak_end']}")
return DEFAULTS['off_peak_start'] <= current_hour or current_hour < DEFAULTS['off_peak_end']
start = DEFAULTS['off_peak_start']
end = DEFAULTS['off_peak_end']
logging.debug(f"Current hour: {current_hour}, Off-peak hours: {start} - {end}")
if start < end:
return start <= current_hour < end
else:
return current_hour >= start or current_hour < end

0 comments on commit d2db7c9

Please sign in to comment.