Attempt to work around timezones
This commit is contained in:
@@ -2,25 +2,25 @@ import logging
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from libbot.pyrogram.classes import PyroClient
|
||||
from pytz import timezone as pytz_timezone
|
||||
|
||||
from classes.enums import GarbageType
|
||||
from classes.location import Location
|
||||
from classes.pyrouser import PyroUser
|
||||
from modules.database import col_entries, col_users
|
||||
from modules.utils import from_utc
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def remind(app: PyroClient) -> None:
|
||||
now = datetime.now()
|
||||
utcnow = datetime.utcnow()
|
||||
|
||||
users = await col_users.find(
|
||||
{"time_hour": now.hour, "time_minute": now.minute}
|
||||
{"time_hour": utcnow.hour, "time_minute": utcnow.minute}
|
||||
).to_list()
|
||||
|
||||
for user_db in users:
|
||||
user = PyroUser(**user_db)
|
||||
user = await PyroUser.from_dict(**user_db)
|
||||
|
||||
if not user.enabled or user.location is None:
|
||||
continue
|
||||
@@ -30,12 +30,10 @@ async def remind(app: PyroClient) -> None:
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
user_date = (
|
||||
datetime.now(pytz_timezone(location.timezone)).replace(
|
||||
second=0, microsecond=0
|
||||
)
|
||||
+ timedelta(days=user.offset)
|
||||
).replace(tzinfo=timezone.utc)
|
||||
user_date = from_utc(
|
||||
datetime(1970, 1, 1, user.time_hour, user.time_minute),
|
||||
user.location.timezone.zone,
|
||||
)
|
||||
|
||||
entries = await col_entries.find(
|
||||
{
|
||||
|
Reference in New Issue
Block a user