Skip to content

Instantly share code, notes, and snippets.

@voroninman
Created November 22, 2017 19:21
Show Gist options
  • Save voroninman/a5ac931b573b48d0d49f884cf8fb5656 to your computer and use it in GitHub Desktop.
Save voroninman/a5ac931b573b48d0d49f884cf8fb5656 to your computer and use it in GitHub Desktop.
from datetime import datetime, timedelta
TODAY = datetime.now().date()
def years_ago(date, years=25):
try:
date_past = date.replace(year=date.year-years)
except ValueError:
date_past = date.replace(year=date.year-years, day=date.day-1)
return date_past
for n in range(5*365):
date_future = TODAY + timedelta(days=n)
date_past = years_ago(date_future)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment