mirror of
https://github.com/Xevion/banner.git
synced 2025-12-07 11:14:26 -06:00
Fix incorrect term format decisions (Fall is NEXT year, not current year)
This commit is contained in:
@@ -332,7 +332,8 @@ func TimeCommandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) er
|
|||||||
fetch_time := time.Now()
|
fetch_time := time.Now()
|
||||||
crn := i.ApplicationCommandData().Options[0].IntValue()
|
crn := i.ApplicationCommandData().Options[0].IntValue()
|
||||||
|
|
||||||
meetingTimes, err := GetCourseMeetingTime(202420, int(crn))
|
// Fix static term
|
||||||
|
meetingTimes, err := GetCourseMeetingTime(202510, int(crn))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
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)
|
return fmt.Errorf("Error retrieving course data: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix static term
|
||||||
meetingTimes, err := GetCourseMeetingTime(202420, int(crn))
|
meetingTimes, err := GetCourseMeetingTime(202420, int(crn))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error requesting meeting time: %w", err)
|
return fmt.Errorf("Error requesting meeting time: %w", err)
|
||||||
|
|||||||
9
term.go
9
term.go
@@ -71,6 +71,11 @@ func GetCurrentTerm(now time.Time) (*Term, *Term) {
|
|||||||
year := uint16(now.Year())
|
year := uint16(now.Year())
|
||||||
dayOfYear := uint16(now.YearDay())
|
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) {
|
if (dayOfYear < SpringRange.Start) || (dayOfYear >= FallRange.End) {
|
||||||
// Fall over, Spring not yet begun
|
// Fall over, Spring not yet begun
|
||||||
return nil, &Term{Year: year + 1, Season: Spring}
|
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}
|
return &Term{Year: year, Season: Summer}, &Term{Year: year, Season: Fall}
|
||||||
} else if dayOfYear < FallRange.Start {
|
} else if dayOfYear < FallRange.Start {
|
||||||
// Summer over, Fall not yet begun
|
// 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) {
|
} else if (dayOfYear >= FallRange.Start) && (dayOfYear < FallRange.End) {
|
||||||
// Fall
|
// 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))
|
panic(fmt.Sprintf("Impossible Code Reached (dayOfYear: %d)", dayOfYear))
|
||||||
|
|||||||
Reference in New Issue
Block a user