feat: added a util function for converting datetimes to iso 8601 strings
This commit is contained in:
parent
48523895e9
commit
eb9640e54f
1 changed files with 11 additions and 0 deletions
|
@ -11,3 +11,14 @@ def convert_str_to_datetime(date_string: str) -> datetime:
|
||||||
datetime: Datetime object
|
datetime: Datetime object
|
||||||
"""
|
"""
|
||||||
return datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')
|
return datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')
|
||||||
|
|
||||||
|
def convert_datetime_to_str(datetime: datetime) -> str:
|
||||||
|
"""Converts a datetime object to a Zipline (`ISO 8601`) date string
|
||||||
|
|
||||||
|
Args:
|
||||||
|
datetime: Datetime to convert
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Converted date string
|
||||||
|
"""
|
||||||
|
return datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%fZ')
|
||||||
|
|
Loading…
Reference in a new issue