Spaces:
ahadi
/
Build error

File size: 517 Bytes
d661b19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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')