Created
May 24, 2018 08:33
-
-
Save RussellLuo/5fd82374aae5e78d5e10a907b7880b08 to your computer and use it in GitHub Desktop.
Returns a list of time tuples that represents a series of timespans between a time 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
# -*- coding: utf-8 -*- | |
def time_span_range(begin, end, span): | |
"""Returns a list of time tuples that represents a series of timespans between a time range. | |
:param begin: begin time | |
:param end: end time | |
:param span: span of each timespan | |
""" | |
s_end = begin | |
while True: | |
s_begin = s_end | |
s_end = s_begin + span | |
if s_end >= end: | |
break | |
yield s_begin, s_end | |
yield s_begin, end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment