Skip to content

Instantly share code, notes, and snippets.

@tripleo1
Created June 18, 2021 11:47
Show Gist options
  • Save tripleo1/a5678951729f7379fd48d989cc4c9acf to your computer and use it in GitHub Desktop.
Save tripleo1/a5678951729f7379fd48d989cc4c9acf to your computer and use it in GitHub Desktop.
Calculate every interval of days between 2 dates.
import datetime
import sys
year = int(sys.argv[1])
def calculate(year):
dt1 = datetime.datetime(year, 1, 1)
yield ("A", dt1)
dt2 = datetime.timedelta(days=14)
for i in range(25):
yield (chr(66+i),dt1+dt2)
dt1=dt1+dt2
for letter, date in calculate(year):
real_date = date.strftime("%Y %b %d")
print (letter, real_date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment