fix: include time zone name overrides and add KOITO_FORCE_TZ cfg option (#176)

* timezone overrides and force_tz option

* docs for force_tz

* add link to time zone names in docs
This commit is contained in:
Gabe Farrell 2026-01-24 13:19:04 -05:00 committed by GitHub
parent 1ed055d098
commit 937f9062b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 153 additions and 1 deletions

View file

@ -49,6 +49,7 @@ const (
FETCH_IMAGES_DURING_IMPORT_ENV = "KOITO_FETCH_IMAGES_DURING_IMPORT"
ARTIST_SEPARATORS_ENV = "KOITO_ARTIST_SEPARATORS_REGEX"
LOGIN_GATE_ENV = "KOITO_LOGIN_GATE"
FORCE_TZ = "KOITO_FORCE_TZ"
)
type config struct {
@ -87,6 +88,7 @@ type config struct {
importAfter time.Time
artistSeparators []*regexp.Regexp
loginGate bool
forceTZ *time.Location
}
var (
@ -213,6 +215,13 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
cfg.loginGate = true
}
if getenv(FORCE_TZ) != "" {
cfg.forceTZ, err = time.LoadLocation(getenv(FORCE_TZ))
if err != nil {
return nil, fmt.Errorf("forced timezone '%s' is not a valid timezone", getenv(FORCE_TZ))
}
}
switch strings.ToLower(getenv(LOG_LEVEL_ENV)) {
case "debug":
cfg.logLevel = 0
@ -430,3 +439,9 @@ func LoginGate() bool {
defer lock.RUnlock()
return globalConfig.loginGate
}
func ForceTZ() *time.Location {
lock.RLock()
defer lock.RUnlock()
return globalConfig.forceTZ
}