1+ """Utilities for determining the current Drexel quarter based on date."""
2+
13from datetime import datetime
2- from typing import Tuple
34
45
5- def get_current_quarter_and_year () -> Tuple [str , str ]:
6+ def get_current_quarter_and_year () -> tuple [str , str ]:
67 """
78 Determine the current Drexel quarter and year based on the current date.
8-
9+
910 Drexel quarters:
1011 - Fall (15): July 1 - September 27
1112 - Winter (25): September 28 - January 15
1213 - Spring (35): January 16 - April 14
1314 - Summer (45): April 15 - June 30
14-
15+
1516 Returns:
1617 Tuple of (year, quarter_code) as strings
1718 """
1819 now = datetime .now ()
1920 month = now .month
2021 day = now .day
2122 year = now .year
22-
23+
2324 # 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 ):
2526 # Fall quarter
2627 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+ ):
2835 # Winter quarter
2936 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+ ):
3143 # Spring quarter
3244 quarter = "35"
3345 else :
3446 # Summer quarter (April 15 - June 30)
3547 quarter = "45"
36-
48+
3749 # For Winter quarter spanning two calendar years (Sept 28 - Jan 15),
3850 # if we're in January, it belongs to the previous year's academic year
3951 if quarter == "25" and month == 1 :
4052 year = year - 1
41-
53+
4254 return str (year ), quarter
4355
4456
@@ -48,7 +60,7 @@ def get_quarter_name(quarter_code: str) -> str:
4860 "15" : "Fall" ,
4961 "25" : "Winter" ,
5062 "35" : "Spring" ,
51- "45" : "Summer"
63+ "45" : "Summer" ,
5264 }
5365 return quarter_names .get (quarter_code , "Unknown" )
5466
0 commit comments