luscenje_struktur/src/time_info.py
2019-08-21 11:13:23 +02:00

19 lines
538 B
Python

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")))