-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclock.py
More file actions
35 lines (22 loc) · 670 Bytes
/
Copy pathclock.py
File metadata and controls
35 lines (22 loc) · 670 Bytes
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
33
34
35
from time import time, localtime, strftime
def get_time() -> str:
return strftime('%Y%m%d%H', localtime(time()))
def get_day() -> str:
return day(get_time())
def day(time_str: str) -> str:
return time_str[:-2]
class TimeController:
def __init__(self):
self.pre = get_time()
def update(self):
self.pre = get_time()
def is_day_change(self):
now = day(get_time())
is_day_changed = now != day(self.pre)
self.update()
return is_day_changed
def is_hour_change(self):
now = get_time()
is_hour_changed = self.pre != now
self.update()
return is_hour_changed