From 394af95c31772acff8d77c8527b6f18fe3315719 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Sat, 16 Dec 2023 22:53:10 +0530 Subject: [PATCH] docs: month_diff and time_diff --- frappe/utils/data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/utils/data.py b/frappe/utils/data.py index f54ffe364e..c817eeb2c7 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -300,13 +300,17 @@ def days_diff(string_ed_date: DateTimeLikeObject, string_st_date: DateTimeLikeOb return (getdate(string_ed_date) - getdate(string_st_date)).days -def month_diff(string_ed_date, string_st_date): +def month_diff(string_ed_date: DateTimeLikeObject, string_st_date: DateTimeLikeObject) -> int: + """Returns the difference between given two dates in months.""" ed_date = getdate(string_ed_date) st_date = getdate(string_st_date) return (ed_date.year - st_date.year) * 12 + ed_date.month - st_date.month + 1 -def time_diff(string_ed_date, string_st_date): +def time_diff( + string_ed_date: DateTimeLikeObject, string_st_date: DateTimeLikeObject +) -> datetime.timedelta: + """Returns the difference between given two dates as `datetime.timedelta` object.""" return get_datetime(string_ed_date) - get_datetime(string_st_date)