mirror of
https://github.com/Xevion/banner.git
synced 2025-12-11 06:06:38 -06:00
Encapsulate default term selection into term.go
This commit is contained in:
9
term.go
9
term.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user