-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
47 lines (38 loc) · 1.34 KB
/
utils.py
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
36
37
38
39
40
41
42
43
44
45
46
47
from datetime import datetime
Y = datetime.now().year
SUMMER_DAY = datetime(Y,12,21).date().timetuple().tm_yday
AUTUMN_DAY = datetime(Y,3,21).date().timetuple().tm_yday
WINTER_DAY = datetime(Y,6,21).date().timetuple().tm_yday
SPRING_DAY = datetime(Y,9,21).date().timetuple().tm_yday
class StationsSTR:
def __init__(self) -> None:
self.SUMMER = "Summer"
self.AUTUMN = "Autumn"
self.WINTER = "Winter"
self.SPRING = "Spring"
class Stations:
def __init__(self) -> None:
self.AUTUMN = range(AUTUMN_DAY,WINTER_DAY)
self.WINTER = range(WINTER_DAY,SPRING_DAY)
self.SPRING = range(SPRING_DAY,SUMMER_DAY)
def checkTime ():
today = datetime.now().timetuple().tm_yday
stations = Stations()
st = StationsSTR()
if today in stations.SPRING:
return st.SPRING
elif today in stations.AUTUMN:
return st.AUTUMN
elif today in stations.WINTER:
return st.WINTER
else:
return st.SUMMER
def leftingDaysForSummer ():
today_number = datetime.now().timetuple().tm_yday
today = datetime.now().date()
st = Stations()
summer_date = datetime(Y,12,21).date()
if not (today_number in st.SPRING or today_number in st.WINTER or today_number in st.AUTUMN):
return None
else:
return int(str(summer_date - today).split(' ')[0])