Calculate prize of rental
This commit is contained in:
24
billard/utils.py
Normal file
24
billard/utils.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from datetime import datetime, date, time
|
||||
|
||||
|
||||
def get_prize_for(start, end=datetime.now(), pph=0):
|
||||
'''
|
||||
calculate prize of billard table rental
|
||||
|
||||
:param start: start datetime of rental
|
||||
:param end: end datetime of rental
|
||||
:param pph: prize per hour of rental
|
||||
:return: the calculated prize of rental
|
||||
'''
|
||||
pps = pph / 3600
|
||||
time = (end - start).seconds
|
||||
prize = round((pps * time), 1)
|
||||
print(prize)
|
||||
return prize
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
d = date(2017, 2, 5)
|
||||
t = time(16, 00)
|
||||
start = datetime.combine(d, t)
|
||||
get_prize_for(start=start, pph=8.5)
|
||||
Reference in New Issue
Block a user