Attempt to work around timezones
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Union
|
||||
|
||||
from bson import ObjectId
|
||||
from pytz import timezone as pytz_timezone
|
||||
from pytz.tzinfo import BaseTzInfo, DstTzInfo
|
||||
|
||||
from classes.point import Point
|
||||
from modules.database import col_locations
|
||||
@@ -22,7 +25,7 @@ class Location:
|
||||
name: str
|
||||
location: Point
|
||||
country: int
|
||||
timezone: str
|
||||
timezone: Union[BaseTzInfo, DstTzInfo]
|
||||
|
||||
@classmethod
|
||||
async def get(cls, id: int):
|
||||
@@ -32,6 +35,7 @@ class Location:
|
||||
raise ValueError(f"No location with ID {id} found.")
|
||||
|
||||
db_entry["location"] = Point(*db_entry["location"]) # type: ignore
|
||||
db_entry["timezone"] = pytz_timezone(db_entry["timezone"]) # type: ignore
|
||||
|
||||
return cls(**db_entry)
|
||||
|
||||
@@ -43,6 +47,7 @@ class Location:
|
||||
raise ValueError(f"No location with name {name} found.")
|
||||
|
||||
db_entry["location"] = Point(*db_entry["location"]) # type: ignore
|
||||
db_entry["timezone"] = pytz_timezone(db_entry["timezone"]) # type: ignore
|
||||
|
||||
return cls(**db_entry)
|
||||
|
||||
@@ -54,5 +59,6 @@ class Location:
|
||||
raise ValueError(f"No location near {lat}, {lon} found.")
|
||||
|
||||
db_entry["location"] = Point(*db_entry["location"]) # type: ignore
|
||||
db_entry["timezone"] = pytz_timezone(db_entry["timezone"]) # type: ignore
|
||||
|
||||
return cls(**db_entry)
|
||||
|
Reference in New Issue
Block a user