class timeslice:
def __init__(self,start,step,max):
self.start = start
self.current = start
self.step = step
self.max = max
def __iter__(self):
return self
def next(self):
current = "%02d:%02d:00"%(self.current/60,self.current%60)
if self.current <= self.max:
self.current += self.step
return current
else:
raise StopIteration
if __name__=='__main__':
ts = timeslice(0,30,60 * 10) # 10 hours
for t in ts:
print t
|