1
+ """Utilities for determining the current Drexel quarter based on date."""
2
+
1
3
from datetime import datetime
2
- from typing import Tuple
3
4
4
5
5
- def get_current_quarter_and_year () -> Tuple [str , str ]:
6
+ def get_current_quarter_and_year () -> tuple [str , str ]:
6
7
"""
7
8
Determine the current Drexel quarter and year based on the current date.
8
-
9
+
9
10
Drexel quarters:
10
11
- Fall (15): July 1 - September 27
11
12
- Winter (25): September 28 - January 15
12
13
- Spring (35): January 16 - April 14
13
14
- Summer (45): April 15 - June 30
14
-
15
+
15
16
Returns:
16
17
Tuple of (year, quarter_code) as strings
17
18
"""
18
19
now = datetime .now ()
19
20
month = now .month
20
21
day = now .day
21
22
year = now .year
22
-
23
+
23
24
# Determine quarter based on month and day
24
- if ( month == 7 ) or ( month == 8 ) or (month == 9 and day <= 27 ):
25
+ if month == 7 or month == 8 or (month == 9 and day <= 27 ):
25
26
# Fall quarter
26
27
quarter = "15"
27
- elif (month == 9 and day >= 28 ) or month == 10 or month == 11 or month == 12 or (month == 1 and day <= 15 ):
28
+ elif (
29
+ (month == 9 and day >= 28 )
30
+ or month == 10
31
+ or month == 11
32
+ or month == 12
33
+ or (month == 1 and day <= 15 )
34
+ ):
28
35
# Winter quarter
29
36
quarter = "25"
30
- elif (month == 1 and day >= 16 ) or month == 2 or month == 3 or (month == 4 and day <= 14 ):
37
+ elif (
38
+ (month == 1 and day >= 16 )
39
+ or month == 2
40
+ or month == 3
41
+ or (month == 4 and day <= 14 )
42
+ ):
31
43
# Spring quarter
32
44
quarter = "35"
33
45
else :
34
46
# Summer quarter (April 15 - June 30)
35
47
quarter = "45"
36
-
48
+
37
49
# For Winter quarter spanning two calendar years (Sept 28 - Jan 15),
38
50
# if we're in January, it belongs to the previous year's academic year
39
51
if quarter == "25" and month == 1 :
40
52
year = year - 1
41
-
53
+
42
54
return str (year ), quarter
43
55
44
56
@@ -48,7 +60,7 @@ def get_quarter_name(quarter_code: str) -> str:
48
60
"15" : "Fall" ,
49
61
"25" : "Winter" ,
50
62
"35" : "Spring" ,
51
- "45" : "Summer"
63
+ "45" : "Summer" ,
52
64
}
53
65
return quarter_names .get (quarter_code , "Unknown" )
54
66
0 commit comments