Skip to content

Instantly share code, notes, and snippets.

@sharuzzaman
Created July 6, 2022 16:33
Show Gist options
  • Select an option

  • Save sharuzzaman/785e5fa6352279cafbe9190200aabcbf to your computer and use it in GitHub Desktop.

Select an option

Save sharuzzaman/785e5fa6352279cafbe9190200aabcbf to your computer and use it in GitHub Desktop.
friday the 13th
from datetime import datetime
from datetime import timedelta
from datetime import date
def friday_the_13th():
today = date.today()
current_month = today.month
current_year = today.year
a = []
a.append(date(current_year,current_month,13))
for c in range(24):
if current_month == 12:
current_month = 1
current_year = current_year + 1
else:
current_month = current_month + 1
a.append(date(current_year,current_month,13))
for b in a:
if b < today:
next
else:
if b.weekday() == 4:
return "{}-{:02d}-{}".format(b.year,b.month,b.day)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment