Last active
          January 25, 2019 15:57 
        
      - 
      
- 
        Save phrz/5f3121cf569b33ef33f7064c67d7522e to your computer and use it in GitHub Desktop. 
Revisions
- 
        phrz revised this gist Jan 25, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ sums = {} last_start = None t = lambda s: int(s[:2])*60*60 + int(s[2:4])*60 # HHMM to seconds since previous 00:00 while True: try: @@ -15,7 +15,6 @@ if line == '': continue start, task = line.split(' ', 1) if last_start: sums[last_task] = t(start) - t(last_start) + sums.get(last_task, 0.0) last_start, last_task = start, task 
- 
        phrz created this gist Jan 25, 2019 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ import time print('SCHEDULE ENTRY', '='*50, sep='\n') print('[Input schedule lines "HHMM <task>". Ends when <task> is "end"]\n') sums = {} last_start = None t = time.mktime while True: try: line = input() except EOFError: break if line == '': continue start, task = line.split(' ', 1) start = time.strptime(start, '%H%M') if last_start: sums[last_task] = t(start) - t(last_start) + sums.get(last_task, 0.0) last_start, last_task = start, task if task == 'end': break print('\nSummary:',*[f'{seconds/(60*60)} {task}' for task, seconds in sums.items()], sep='\n')