-
Notifications
You must be signed in to change notification settings - Fork 0
/
payhours.py
57 lines (47 loc) · 1.58 KB
/
payhours.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import datetime,colorama
REQUIRED_WORKING_HOURS_EACH_DAY = 9
now = datetime.datetime.now()
today = now.today().day
restDays = [4,5]
businessdays = 0
vacations = 0
lastday = 0
while True:
try:
alreadyDone = float(raw_input("Enter number of hours already done: \n"))
except Exception:
print "Invalid number!"
continue
break
while True:
try:
vacations = int(raw_input("Enter number of day-offs/holidays/vacations: \n"))
except Exception:
print "Invalid number!"
continue
break
for i in range(1, 32):
try:
thisdate = datetime.date(now.year, now.month, i)
lastday = i
except(ValueError):
break
if thisdate.weekday() not in restDays:
businessdays += 1
total = (businessdays - vacations) * REQUIRED_WORKING_HOURS_EACH_DAY
dayleft = (lastday - today) + 1
for i in range(1, dayleft):
try:
date = datetime.date(now.year, now.month, i)
except(ValueError):
break
if date.weekday() in restDays:
dayleft -= 1
print "---------------------------"
print "Total number of hours to work this month: {}".format(total)
print "Number of hours already done this month: {}".format(alreadyDone)
print "Number of hours left to work this month: {}".format(total-alreadyDone)
print "Number of days left to work this month: {}".format(dayleft)
print "Average of hours left to work each day this month: {}".format((total-alreadyDone)/float(dayleft))
print "---------------------------"
raw_input("Press any key to exit...")