2021-11-19 14:47:04 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
|
|
|
|
class Stopwatch:
|
2021-11-19 14:47:04 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.start_time = datetime.datetime.utcnow()
|
2021-11-19 15:24:39 +00:00
|
|
|
self.start_time_str_value = self.start_time.strftime("%Y-%m-%d %H:%M:%S")
|
2021-11-19 14:47:04 +00:00
|
|
|
|
|
|
|
@property
|
2023-01-03 11:55:12 +00:00
|
|
|
def duration_seconds(self) -> float:
|
2021-11-19 14:47:04 +00:00
|
|
|
return (datetime.datetime.utcnow() - self.start_time).total_seconds()
|
|
|
|
|
|
|
|
@property
|
2023-01-03 11:55:12 +00:00
|
|
|
def start_time_str(self) -> str:
|
2021-11-19 15:24:39 +00:00
|
|
|
return self.start_time_str_value
|