Skip to content

Commit

Permalink
Adjusted README.md + added docstring for Result class
Browse files Browse the repository at this point in the history
  • Loading branch information
Inf-inity committed Oct 29, 2022
1 parent c159fca commit 4a2449e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ Below you can find some examples of how datetimeparser can be used.
```python
from datetimeparser import parse

print(parse("next 3 years and 2 months"))
# <Result: time='2025-12-28 11:57:25', timezone='Europe/Berlin', coordinates='None'>
print(parse("next 3 years and 2 months").time)
# 2025-12-28 11:57:25

print(parse("begin of advent of code 2022"))
# <Result: time='2022-12-01 06:00:00', timezone='Europe/Berlin', coordinates='None'>
print(parse("begin of advent of code 2022").time)
# 2022-12-01 06:00:00

print(parse("in 1 Year 2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds"))
# <Result: time='2024-01-22 17:04:26', timezone='Europe/Berlin', coordinates='None'>
print(parse("in 1 Year 2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds").time)
# 2024-01-22 17:04:26

print(parse("10 days and 2 hours after 3 months before christmas 2020"))
# <Result: time='2020-10-05 02:00:00', timezone='Europe/Berlin', coordinates='None'>
print(parse("10 days and 2 hours after 3 months before christmas 2020").time)
# 2020-10-05 02:00:00

print(parse("sunrise"))
# <Result: time='2022-10-28 08:15:19', timezone='Europe/Berlin', coordinates=[longitude='7.188402', latitude='50.652927999999996]'>
Expand Down
9 changes: 9 additions & 0 deletions datetimeparser/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@


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]
Expand Down

0 comments on commit 4a2449e

Please sign in to comment.