Skip to content

Instantly share code, notes, and snippets.

@cosmin
Created August 12, 2011 16:01
Show Gist options
  • Save cosmin/1142361 to your computer and use it in GitHub Desktop.
Save cosmin/1142361 to your computer and use it in GitHub Desktop.
range equivalent for datetime
import datetime
def daterange(start_or_end, end=None, step=datetime.timedelta(1)):
"daterange([start,] stop[, step]) -> list of dates"
if end == None:
end = start_or_end
start = datetime.date.today()
current = start
while current < end:
yield current
current = current + step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment