Skip to content

Instantly share code, notes, and snippets.

@kitsunde
Last active December 10, 2015 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsunde/4470659 to your computer and use it in GitHub Desktop.
Save kitsunde/4470659 to your computer and use it in GitHub Desktop.
#Build a date range with the start of the previous/upcomming months.
now = timezone.now()
current_date = now.date()
months = []
for month_adjust in range(-2, 3):
month = (now.month + month_adjust) % 12
if month == 0: month = 12
months.append(current_date.replace(month=month, day=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment