Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generates 15 minute sessions times when given an interval in time.
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