Created
August 19, 2015 18:24
-
-
Save stantonk/62969c406f73dcb72227 to your computer and use it in GitHub Desktop.
python datetime xrange generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def date_xrange(s_dt, e_dt, inclusive=False): | |
ONE_DAY = timedelta(days=1) | |
days = (e_dt - s_dt).days | |
days = days + 1 if inclusive else days | |
return (s_dt + i*ONE_DAY for i in range(0, days)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment