Fix incorrect term format decisions (Fall is NEXT year, not current year)

This commit is contained in:
2024-09-10 13:41:01 -05:00
parent 6fd2d6fc7d
commit c850acffcd
2 changed files with 10 additions and 3 deletions

View File

@@ -332,7 +332,8 @@ func TimeCommandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) er
fetch_time := time.Now()
crn := i.ApplicationCommandData().Options[0].IntValue()
meetingTimes, err := GetCourseMeetingTime(202420, int(crn))
// Fix static term
meetingTimes, err := GetCourseMeetingTime(202510, int(crn))
if err != nil {
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
@@ -400,6 +401,7 @@ func IcsCommandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) err
return fmt.Errorf("Error retrieving course data: %w", err)
}
// Fix static term
meetingTimes, err := GetCourseMeetingTime(202420, int(crn))
if err != nil {
return fmt.Errorf("Error requesting meeting time: %w", err)

View File

@@ -71,6 +71,11 @@ func GetCurrentTerm(now time.Time) (*Term, *Term) {
year := uint16(now.Year())
dayOfYear := uint16(now.YearDay())
// Fall of 2024 => 202410
// Spring of 2024 => 202420
// Fall of 2025 => 202510
// Summer of 2025 => 202530
if (dayOfYear < SpringRange.Start) || (dayOfYear >= FallRange.End) {
// Fall over, Spring not yet begun
return nil, &Term{Year: year + 1, Season: Spring}
@@ -85,10 +90,10 @@ func GetCurrentTerm(now time.Time) (*Term, *Term) {
return &Term{Year: year, Season: Summer}, &Term{Year: year, Season: Fall}
} else if dayOfYear < FallRange.Start {
// Summer over, Fall not yet begun
return nil, &Term{Year: year, Season: Fall}
return nil, &Term{Year: year + 1, Season: Fall}
} else if (dayOfYear >= FallRange.Start) && (dayOfYear < FallRange.End) {
// Fall
return &Term{Year: year, Season: Fall}, nil
return &Term{Year: year + 1, Season: Fall}, nil
}
panic(fmt.Sprintf("Impossible Code Reached (dayOfYear: %d)", dayOfYear))