luscenje_struktur/src/time_info.py

19 lines
538 B
Python
Raw Normal View History

2019-08-21 09:13:23 +00:00
from datetime import timedelta, datetime
class TimeInfo:
def __init__(self, to_go):
self.times = []
self.to_go = to_go
def add_measurement(self, time_measurement):
if time_measurement > 0:
self.times.append(time_measurement)
self.to_go -= 1
def info(self):
seconds = sum(self.times) / len(self.times)
td = timedelta(seconds = int(seconds * self.to_go))
ft = datetime.now() + td
print("Going to finish in {}".format(ft.strftime("%d/%m @ %H:%M")))