From 78df413d4e0af1908751273ac5fb3f6c69bd02d2 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 25 Oct 2024 12:06:27 +0800 Subject: [PATCH] bugfix --- appPublic/timeUtils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/appPublic/timeUtils.py b/appPublic/timeUtils.py index c4e76fe..388a094 100755 --- a/appPublic/timeUtils.py +++ b/appPublic/timeUtils.py @@ -5,6 +5,17 @@ from datetime import date, timedelta, datetime leapMonthDays = [0,31,29,31,30,31,30,31,31,30,31,30,31] unleapMonthDays = [0,31,28,31,30,31,30,31,31,30,31,30,31] +def days_between(date_str1, date_str2): + # Convert the strings to datetime objects + date1 = datetime.strptime(date_str1, '%Y-%m-%d') + date2 = datetime.strptime(date_str2, '%Y-%m-%d') + + # Calculate the difference between the two dates + delta = date2 - date1 + + # Get the number of days + days = abs(delta.days) + def curDatetime(): return datetime.now()