Добавить last_friday_datetime.py

This commit is contained in:
Войтенко 2026-05-05 13:13:08 +00:00
parent 5b9cb8fe2c
commit afcb8a04c8

19
last_friday_datetime.py Normal file
View File

@ -0,0 +1,19 @@
import datetime
def get_last_friday(date_string):
parts = date_string.split("/")
mounth = int(части[0])
year = int(части[1])
if mounth == 12:
first = datetime.data(year +1,1,1)
else:
first = datetime.date(year,mounth+1,1)
last = first - datetime.timedelta(days=1)
now = last
while True:
if now.isoweekday() ==5:
break
else:
now = now - datetime.timedelta(days=1)
result = now.strftime("%d.%m.%Y")
return result