Skip to content

Commit

Permalink
feat: create empty value when date_time is None in create_from_string
Browse files Browse the repository at this point in the history
  • Loading branch information
fbraem committed Oct 2, 2023
1 parent 625a478 commit 91b5611
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ def create_now(cls):

@classmethod
def create_from_string(
cls, date_time: str, date_format: str = "%Y-%m-%d %H:%M:%S"
cls, date_time: str | None = None, date_format: str = "%Y-%m-%d %H:%M:%S"
) -> "LocalTimestamp":
"""Create a timestamp from a string.
Args:
date_time: The string to convert to a timestamp.
date_format: The format used in the string.
"""
if date_time is None:
return LocalTimestamp()
return LocalTimestamp(datetime.strptime(date_time, date_format))

0 comments on commit 91b5611

Please sign in to comment.