mirror of
https://github.com/Xevion/banner.git
synced 2025-12-15 00:11:06 -06:00
feat: move default term acquisition & season range from global into config state, LoadLocation once, remove bare constants
This commit is contained in:
@@ -26,12 +26,10 @@ type Config struct {
|
||||
Environment string
|
||||
// CentralTimeLocation is the time.Location for US Central Time.
|
||||
CentralTimeLocation *time.Location
|
||||
// SeasonRanges is the time.Location for US Central Time.
|
||||
SeasonRanges *SeasonRanges
|
||||
}
|
||||
|
||||
const (
|
||||
CentralTimezoneName = "America/Chicago"
|
||||
)
|
||||
|
||||
// New creates a new Config instance with a cancellable context.
|
||||
func New() (*Config, error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@@ -42,10 +40,13 @@ func New() (*Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
seasonRanges := GetYearDayRange(loc, uint16(time.Now().Year()))
|
||||
|
||||
return &Config{
|
||||
Ctx: ctx,
|
||||
CancelFunc: cancel,
|
||||
CentralTimeLocation: loc,
|
||||
SeasonRanges: &seasonRanges,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user