gear-orders/util.py

26 lines
540 B
Python
Raw Normal View History

2025-11-14 04:03:20 +00:00
import aiohttp
2025-11-14 04:03:20 +00:00
import pytz
import datetime
2026-03-07 02:26:56 +00:00
from settings import TIMEZONE
2025-11-14 04:03:20 +00:00
def make_session():
return aiohttp.ClientSession()
2025-11-14 04:03:20 +00:00
def timezone():
return pytz.timezone(TIMEZONE)
2025-11-14 04:03:20 +00:00
2026-03-07 00:33:08 +00:00
def sqlite_time(dt):
return dt.astimezone(datetime.UTC).strftime('%Y-%m-%d %H:%M:%S')
2026-03-08 18:44:59 +00:00
def time_sqlite(dt):
return dt.replace(tzinfo=datetime.UTC)
2026-03-04 23:33:17 +00:00
def order_time(str):
order_time_arr = list(map(int, str.split(':')))
2025-11-14 04:03:20 +00:00
return datetime.time(
hour=order_time_arr[0],
minute=order_time_arr[1],
tzinfo=timezone()
2025-11-14 04:03:20 +00:00
)