Created
July 29, 2015 13:31
-
-
Save Visgean/a8ff62fa3485e9250afb to your computer and use it in GitHub Desktop.
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_range(first_date, second_date): | |
| """ | |
| Returns range of dates between first and second date | |
| :type first_date: datetime.date | |
| :type second_date: datetime.date | |
| :return: list of dates | |
| """ | |
| if first_date == second_date: | |
| return [] | |
| elif first_date > second_date: | |
| return date_range(second_date, first_date) | |
| diff = second_date - first_date | |
| return [ | |
| first_date + timedelta(days=x) for x in range(1, diff.days) | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment