-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.py
More file actions
64 lines (56 loc) · 1.44 KB
/
time.py
File metadata and controls
64 lines (56 loc) · 1.44 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from typing import Tuple
def get_day_chinese(digit: int) -> str:
"""
get Chinese char of day of week
"""
if digit == 1:
return '周一'
elif digit == 2:
return '周二'
elif digit == 3:
return '周三'
elif digit == 4:
return '周四'
elif digit == 5:
return '周五'
elif digit == 6:
return '周六'
else:
return '周日'
def get_time_chinese(digit: int) -> str:
"""
get Chinese time description for a single lesson time.
"""
if digit == 1:
return '第1-2节'
elif digit == 2:
return '第3-4节'
elif digit == 3:
return '第5-6节'
elif digit == 4:
return '第7-8节'
elif digit == 5:
return '第9-10节'
else:
return '第11-12节'
def get_time(digit: int) -> Tuple[Tuple[int, int], Tuple[int, int]]:
"""
get start and end time for a single lesson.
"""
if digit == 1:
return (8, 00), (9, 40)
elif digit == 2:
return (10, 00), (11, 40)
elif digit == 3:
return (14, 00), (15, 40)
elif digit == 4:
return (16, 00), (17, 40)
elif digit == 5:
return (19, 00), (20, 40)
else:
return (21, 00), (22, 40)
def lesson_string_to_tuple(lesson: str) -> Tuple[int, int]:
"""transform str like '10102' into tuple like (1,1)"""
day = int(lesson[0])
time = int((int(lesson[2]) + 1) / 2)
return day, time