-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add all documented fields to resources and type annotate them
- Loading branch information
1 parent
5e9b56e
commit 9b093b2
Showing
2 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import datetime as dt | ||
from typing import Optional | ||
|
||
DATE_FORMAT = "%Y-%m-%d" | ||
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" | ||
|
||
|
||
def parse_date(date_str: str) -> Optional[dt.date]: | ||
datetime = parse_datetime(date_str, DATE_FORMAT) | ||
return datetime.date() if datetime else None | ||
|
||
|
||
def parse_datetime( | ||
datetime_str: str, | ||
date_format: str = DATETIME_FORMAT, | ||
) -> Optional[dt.datetime]: | ||
if not datetime_str or datetime_str.startswith("0000-00-00"): | ||
return None | ||
return dt.datetime.strptime(datetime_str, date_format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters