1
0
Fork 0
mirror of https://github.com/TwiN/gatus.git synced 2024-12-14 11:58:04 +00:00

fix(maintenance): Import time/tzdata to support timezones (#849)

Fix #848
This commit is contained in:
TwiN 2024-08-28 18:41:21 -04:00 committed by GitHub
parent d04b68979a
commit 54221eff9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
_ "time/tzdata" // Required for IANA timezone support
) )
var ( var (
@ -52,7 +53,7 @@ func GetDefaultConfig() *Config {
} }
// IsEnabled returns whether maintenance is enabled or not // IsEnabled returns whether maintenance is enabled or not
func (c Config) IsEnabled() bool { func (c *Config) IsEnabled() bool {
if c.Enabled == nil { if c.Enabled == nil {
return true return true
} }
@ -101,7 +102,7 @@ func (c *Config) ValidateAndSetDefaults() error {
} }
// IsUnderMaintenance checks whether the endpoints that Gatus monitors are within the configured maintenance window // IsUnderMaintenance checks whether the endpoints that Gatus monitors are within the configured maintenance window
func (c Config) IsUnderMaintenance() bool { func (c *Config) IsUnderMaintenance() bool {
if !c.IsEnabled() { if !c.IsEnabled() {
return false return false
} }
@ -127,7 +128,7 @@ func (c Config) IsUnderMaintenance() bool {
return now.After(startOfMaintenancePeriod) && now.Before(endOfMaintenancePeriod) return now.After(startOfMaintenancePeriod) && now.Before(endOfMaintenancePeriod)
} }
func (c Config) hasDay(day string) bool { func (c *Config) hasDay(day string) bool {
for _, d := range c.Every { for _, d := range c.Every {
if d == day { if d == day {
return true return true