Compare commits
1 Commits
main
...
natally-pa
| Author | SHA1 | Date | |
|---|---|---|---|
| afcb8a04c8 |
19
last_friday_datetime.py
Normal file
19
last_friday_datetime.py
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user