Skip to content

Instantly share code, notes, and snippets.

@freespace
Created October 9, 2014 12:09
Show Gist options
  • Save freespace/7b0d6f34cc0a4b5cd19a to your computer and use it in GitHub Desktop.
Save freespace/7b0d6f34cc0a4b5cd19a to your computer and use it in GitHub Desktop.
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