Skip to content

Instantly share code, notes, and snippets.

@Ogaday
Created March 9, 2020 13:05
Show Gist options
  • Save Ogaday/e4d70d67fe1c0c7347bc6d86fad0f646 to your computer and use it in GitHub Desktop.
Save Ogaday/e4d70d67fe1c0c7347bc6d86fad0f646 to your computer and use it in GitHub Desktop.
Date Range
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