feat: move default term acquisition & season range from global into config state, LoadLocation once, remove bare constants

This commit is contained in:
2025-08-26 11:53:29 -05:00
parent 5a722d16c6
commit 95e760c549
5 changed files with 48 additions and 42 deletions

View File

@@ -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
}