Created
March 9, 2020 13:05
-
-
Save Ogaday/e4d70d67fe1c0c7347bc6d86fad0f646 to your computer and use it in GitHub Desktop.
Date Range
This file contains 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
from datetime import datetime, timedelta | |
from typing import Iterator | |
def date_range( | |
start: datetime, | |
stop: datetime, | |
step: timedelta | |
) -> Iterator[datetime]: | |
""" | |
Iterate through "step" spaced timestamps | |
""" | |
yield from (start + i * step for i in range((stop - start)//step)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment