From a2fd4905b5daaeff8f895c3c4ac58adedc80fc09 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Sat, 16 Dec 2023 23:08:09 +0530 Subject: [PATCH] refactor(get_timestamp): return current timestamp if date is none --- frappe/utils/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/utils/data.py b/frappe/utils/data.py index 871a9ad5a1..250dc6fb44 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -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())