Coverage for apps/comments_api/utils.py: 83%

6 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-07-18 09:02 +0000

1from datetime import datetime 

2 

3from .constants import API_DATETIME_FORMAT 

4 

5 

6def parse_date(date_str: str, format: str = API_DATETIME_FORMAT) -> datetime: 

7 """Wrapper around `datetime.strptime` with default API date format.""" 

8 return datetime.strptime(date_str, format) 

9 

10 

11def date_to_str(date: datetime, format: str = API_DATETIME_FORMAT) -> str: 

12 """Wrapper around `datetime.strftime` with default API date format.""" 

13 return date.strftime(format)