Created
October 9, 2014 12:09
-
-
Save freespace/7b0d6f34cc0a4b5cd19a to your computer and use it in GitHub Desktop.
Generates 15 minute sessions times when given an interval in time.
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
def sessions(starth, startmin, endh, endmin): | |
""" | |
starth: start hour, 24 hr | |
startm: start minute | |
endh: end hour, 24 hr | |
endmin: end minute | |
""" | |
curh = starth | |
curmin = startmin | |
while curh < endh or curmin< endmin: | |
h12 = curh | |
suffix = 'am' | |
if h12 >=12: | |
suffix = 'pm' | |
if h12 > 12: | |
h12 -= 12 | |
print '%d:%02d %s session'%(h12, curmin, suffix) | |
curmin += 15 | |
if curmin >= 60: | |
curh += 1 | |
curmin = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment