Hotfix for The College Grind

Fixes an issue in the TigerCenter response parser that was causing The College Grind to register as closed every day. The parser now correctly handles exceptions shown for days that they do not apply to.
This commit is contained in:
2026-01-25 00:21:18 -05:00
parent eee7a6687f
commit e761b7ab8a
3 changed files with 17 additions and 11 deletions

View File

@@ -94,10 +94,16 @@ func parseLocationInfo(location: DiningLocationParser, forDate: Date?) -> Dining
var closeStrings: [String] = []
// Dining locations have a regular schedule, but then they also have exceptions listed for days like weekends or holidays. If there
// are exceptions, use those times for the day, otherwise we can just use the default times. Also check for repeats! The response data
// can include those somtimes, for reasons:tm:
// are exceptions, use those times for the day, otherwise we can just use the default times. Also check for repeats! The response
// data can include those somtimes, for reasons:tm:
for event in location.events {
if let exceptions = event.exceptions, !exceptions.isEmpty {
if let exceptions = event.exceptions,
!exceptions.isEmpty,
// This additional check is necessary, because sometimes the exceptions are silly and are doing something like marking
// a location as closed on a day that isn't included in the regular schedule anyway. That breaks things. This check
// ensures that the exception being looked at applies for the day we're parsing for before trying to follow it.
exceptions[0].daysOfWeek.contains(weekdayFromDate.string(from: forDate ?? Date()).uppercased())
{
// Only save the exception times if the location is actually open during those times, and if these times aren't a repeat.
// I've seen repeats for Brick City Cafe specifically, where both the breakfast and lunch standard open periods had
// exceptions listing the same singluar brunch period. That feels like a stupid choice but oh well.
@@ -175,12 +181,11 @@ func parseLocationInfo(location: DiningLocationParser, forDate: Date?) -> Dining
}
}
// Sometimes the openings are not in order, for some reason. I'm observing this with Brick City, where for some reason the early opening
// is event 1, and the later opening is event 0. This is silly so let's reverse it.
// Sometimes the openings are not in order, for some reason. I'm observing this with Brick City, where for some reason the early
// opening is event 1, and the later opening is event 0. This is silly so let's reverse it.
diningTimes.sort { $0.openTime < $1.openTime }
// This can probably be done a little cleaner but it's okay for now. If the location is open but the close date is within the next
// 30 minutes, label it as closing soon, and do the opposite if it's closed but the open date is within the next 30 minutes.
// Get the current open status for a location. Details about how this works can be seen in the docs for parseOpenStatus().
var openStatus: OpenStatus = .closed
for i in diningTimes.indices {
openStatus = parseOpenStatus(openTime: diningTimes[i].openTime, closeTime: diningTimes[i].closeTime, referenceTime: now)

View File

@@ -17,6 +17,7 @@ struct DiningLocationParser: Decodable {
let name: String
let startTime: String
let endTime: String
let daysOfWeek: [String]
let startDate: String
let endDate: String
let open: Bool

View File

@@ -292,7 +292,7 @@
CODE_SIGN_ENTITLEMENTS = TigerDineWidgets/TigerDineWidgets.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = 5GF7GKNTK4;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = TigerDineWidgets/Info.plist;
@@ -325,7 +325,7 @@
CODE_SIGN_ENTITLEMENTS = TigerDineWidgets/TigerDineWidgets.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = 5GF7GKNTK4;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = TigerDineWidgets/Info.plist;
@@ -481,7 +481,7 @@
CODE_SIGN_ENTITLEMENTS = TigerDine/TigerDine.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = 5GF7GKNTK4;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
@@ -518,7 +518,7 @@
CODE_SIGN_ENTITLEMENTS = TigerDine/TigerDine.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = 5GF7GKNTK4;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;