refactor(get_timestamp): return current timestamp if date is none
This commit is contained in:
parent
4992bdf937
commit
a2fd4905b5
1 changed files with 4 additions and 2 deletions
|
|
@ -334,8 +334,10 @@ def now_datetime() -> datetime.datetime:
|
|||
return dt.replace(tzinfo=None)
|
||||
|
||||
|
||||
def get_timestamp(date: DateTimeLikeObject) -> float:
|
||||
"""Returns the Unix timestamp (seconds since Epoch) for the given `date`."""
|
||||
def get_timestamp(date: Optional["DateTimeLikeObject"] = None) -> float:
|
||||
"""Returns the Unix timestamp (seconds since Epoch) for the given `date`.
|
||||
If `date` is None, the current timestamp is returned.
|
||||
"""
|
||||
return time.mktime(getdate(date).timetuple())
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue