# Copyright (C) 2020 * Ltd. All rights reserved. # author : Sanghyeon Jo import time def get_today(): now = time.localtime() s = "%04d-%02d-%02d-%02dh%02dm%02ds" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec) return s class Timer: def __init__(self): self.start_time = 0.0 self.end_time = 0.0 self.tik() def tik(self): self.start_time = time.time() def tok(self, ms = False, clear=False): self.end_time = time.time() if ms: duration = int((self.end_time - self.start_time) * 1000) else: duration = int(self.end_time - self.start_time) if clear: self.tik() return duration