#!/usr/bin/env python
import os
import sys
import datetime

def split(string, divs):
	for d in divs[1:]:
		string = string.replace(d, divs[0])
	return string.split(divs[0])

os.system("grep \"started at\" *out* | awk '{printf \"%s %s\\n\",$1,$8}' > gugus")
os.system("grep \"finished at\" *out* | awk '{printf \"%s %s\\n\",$1,$7}' >> gugus; sort gugus > gugus2")
g = open("gugus2","r")
data=[]
for line in g:
	data.append(line.split())

for i in xrange(0,len(data)-1,2):
	file=data[i][0]
	start = datetime.datetime.strptime(data[i][1], '%H:%M:%S')
	end = datetime.datetime.strptime(data[i+1][1], '%H:%M:%S')
	if end< start:
		difference = start - end
	else:
		difference = end - start
	f = split(file,":. -_")
	print f[5], f[4], f[0], f[3] , difference.seconds
	
