edit_anything / my /utils /ticker.py
memef4rmer's picture
Duplicate from jyseo/3DFuse
efe5745
raw
history blame contribute delete
517 Bytes
from datetime import date, time, datetime, timedelta
from time import sleep
class IntervalTicker():
def __init__(self, interval=60):
self.interval = timedelta(seconds=interval)
self.last_tick = datetime.now()
self.now = self.last_tick
def tick(self):
self.now = datetime.now()
if (self.now - self.last_tick) > self.interval:
self.last_tick = self.now
return True
def tick_str(self):
return self.now.isoformat(timespec='seconds')