Query MongoDB timestamps using normalized ISO string bounds
This commit is contained in:
parent
757eb97be0
commit
ebb3a1fb65
1 changed files with 47 additions and 2 deletions
8
great_ai/helper/normalise_datetime.py
Normal file
8
great_ai/helper/normalise_datetime.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def normalise_datetime(value: datetime) -> datetime:
|
||||
"""Interpret naive timestamps as UTC and normalize aware timestamps to UTC."""
|
||||
return (
|
||||
value.astimezone(timezone.utc).replace(tzinfo=None) if value.tzinfo else value
|
||||
)
|
||||
Loading…
Reference in a new issue