Added overnight sleep for Gerty
This commit is contained in:
@@ -146,5 +146,16 @@ def get_next_update_time(sleep_time_seconds: int = 0, timezone: str = "Europe/Lo
|
||||
utc_now = pytz.utc.localize(datetime.datetime.utcnow())
|
||||
next_refresh_time = utc_now + datetime.timedelta(0, sleep_time_seconds)
|
||||
local_refresh_time = next_refresh_time.astimezone(pytz.timezone(timezone))
|
||||
# datetime.fromtimestamp(time.time()).strftime("%e %b %Y at %H:%M")
|
||||
return "Next update at {0}".format(local_refresh_time.strftime("%H:%M on%e %b %Y"))
|
||||
return "{0} {1}".format("I'll wake up at" if gerty_should_sleep() else "Next update at",local_refresh_time.strftime("%H:%M on%e %b %Y"))
|
||||
|
||||
def gerty_should_sleep(timezone: str = "Europe/London"):
|
||||
utc_now = pytz.utc.localize(datetime.datetime.utcnow())
|
||||
local_time = utc_now.astimezone(pytz.timezone(timezone))
|
||||
hours = local_time.strftime("%H")
|
||||
hours = int(hours)
|
||||
logger.debug("HOURS")
|
||||
logger.debug(hours)
|
||||
if(hours >= 22 and hours <= 23):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user