mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 18:51:05 +01:00
Bug fixes
This commit is contained in:
parent
0b63db46db
commit
aa040f3a6c
@ -1,4 +1,4 @@
|
||||
import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import pytz
|
||||
import httpx
|
||||
import textwrap
|
||||
@ -143,13 +143,13 @@ async def get_mining_stat(stat_slug: str, gerty):
|
||||
return text
|
||||
|
||||
def get_next_update_time(sleep_time_seconds: int = 0, timezone: str = "Europe/London"):
|
||||
utc_now = pytz.utc.localize(datetime.datetime.utcnow())
|
||||
next_refresh_time = utc_now + datetime.timedelta(0, sleep_time_seconds)
|
||||
utc_now = pytz.utc.localize(datetime.utcnow())
|
||||
next_refresh_time = utc_now + timedelta(0, sleep_time_seconds)
|
||||
local_refresh_time = next_refresh_time.astimezone(pytz.timezone(timezone))
|
||||
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"))
|
||||
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())
|
||||
utc_now = pytz.utc.localize(datetime.utcnow())
|
||||
local_time = utc_now.astimezone(pytz.timezone(timezone))
|
||||
hours = local_time.strftime("%H")
|
||||
hours = int(hours)
|
||||
|
@ -138,7 +138,7 @@ async def api_gerty_json(
|
||||
next_screen_number = 0 if ((p + 1) >= enabled_screen_count) else p + 1;
|
||||
|
||||
# get the sleep time
|
||||
sleep_time = gerty.refresh_time
|
||||
sleep_time = gerty.refresh_time if gerty.refresh_time else 300
|
||||
if gerty_should_sleep():
|
||||
sleep_time_hours = 8
|
||||
sleep_time = 60 * 60 * sleep_time_hours
|
||||
|
Loading…
Reference in New Issue
Block a user