Encapsulate default term selection into term.go

This commit is contained in:
2024-01-29 05:28:50 -06:00
parent c5ad772ebc
commit 281944546f
2 changed files with 12 additions and 9 deletions

View File

@@ -129,3 +129,12 @@ func (term Term) ToString() string {
return fmt.Sprintf("%d%s", term.Year, season)
}
// Default chooses the default term, which is the current term if it exists, otherwise the next term.
func Default(t time.Time) Term {
currentTerm, nextTerm := GetCurrentTerm(t)
if currentTerm == nil {
return *nextTerm
}
return *currentTerm
}