Spaces:
Sleeping
Sleeping
File size: 815 Bytes
c20a1af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# Copyright (C) 2020 * Ltd. All rights reserved.
# author : Sanghyeon Jo <[email protected]>
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 |