Skip to content

Commit

Permalink
fix bug again
Browse files Browse the repository at this point in the history
  • Loading branch information
NOOBDY committed Jan 1, 2025
1 parent 9862d2d commit d7c3c55
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions types/semester.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ type Semester struct {
}

func TimeToSemester(t time.Time) Semester {
if t.Month() >= time.September {
return Semester{
year: t.Year(),
period: Fall,
}
} else {
switch t.Month() {
case time.February, time.March, time.April, time.May, time.June, time.July:
return Semester{
year: t.Year() - 1,
period: Spring,
}
case time.August, time.September, time.October, time.November, time.December, time.January:
return Semester{
year: t.Year(),
period: Fall,
}
default:
panic("impossible case: sum type in golang when")
}
}

Expand Down

0 comments on commit d7c3c55

Please sign in to comment.