-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
30 lines (23 loc) · 929 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from datetime import datetime
class Result:
"""
The returned Result by the parse function, containing the output information
- Attributes:
- time (datetime): The parsed time
- timezone (str): The used timezone
- coordinates (Optional[tuple[float, float]]): Coordinates used for parsing
"""
time: datetime
timezone: str
coordinates: tuple[float, float]
def __init__(self, time: datetime, timezone: str, coordinates: tuple[float, float] = None):
self.time = time
self.timezone = timezone
self.coordinates = coordinates
def __repr__(self):
out: str = "'None'"
if self.coordinates:
out: str = f"[longitude='{self.coordinates[0]}', latitude='{self.coordinates[1]}]'"
return f"<Result: time='{self.time}', timezone='{self.timezone}', coordinates={out}>"
def __str__(self):
return self.__repr__()