Thursday, July 23, 2009

My python hours worked calc.

I use this horrid little piece of code to tell me how long i work each day. It isn't all that grate but it gets the job done.

ClockInHoure = 7
ClockInMinuet = 10
ClockOutHoure = 5
ClockOutMinuet = 0
lunchstartHoure = 11
lunchstartMinuet = 28
lunchEndHour = 12
lunchEndMInuets = 05

#caculate hours worked
mHours = 12 - ClockInHoure
aHours = ClockOutHoure
#get theminuets
mMinuets = mHours * 60 - ClockInMinuet
aMinuets = aHours * 60 + ClockOutMinuet

tMins = mMinuets + aMinuets

Lhours = lunchEndHour - lunchstartHoure
lmins = lunchstartMinuet - lunchEndMInuets

bMin = Lhours * 60 - lmins


tMins -= bMin

tHour = tMins / 60
tMinuets = tMins % 60
if(tMinuets < 10):
pMin = "0"+ str(tMinuets)
else:
pMin = str(tMinuets)
print "%d:%s" %(tHour,pMin )

No comments: