diff --git a/app.go b/app.go index 137c314..dbfb2a0 100644 --- a/app.go +++ b/app.go @@ -65,7 +65,6 @@ func (app *App) Start() { Handler: app.router, } - log.Println("Current timezone:", app.cfg.Timezone.String()) app.ResetTimer() log.Printf("Ready, listening on %s\n", app.cfg.Bind) diff --git a/config/cli.go b/config/cli.go index 4677a69..1894daa 100644 --- a/config/cli.go +++ b/config/cli.go @@ -17,7 +17,6 @@ func (c *Config) declareFlags() { flag.StringVar(&c.ActionsDir, "actions-dir", c.ActionsDir, "Path to the directory containing the actions") flag.StringVar(&c.RoutinesDir, "routines-dir", c.RoutinesDir, "Path to the directory containing the routines") flag.IntVar(&c.SampleRate, "samplerate", c.SampleRate, "Samplerate for unifying output stream") - flag.Var(&c.Timezone, "timezone", "Timezone to use when dealing with times") // Others flags are declared in some other files when they need specials configurations } diff --git a/config/config.go b/config/config.go index 26f791a..26fe5c1 100644 --- a/config/config.go +++ b/config/config.go @@ -18,7 +18,6 @@ type Config struct { ActionsDir string RoutinesDir string - Timezone Timezone SampleRate int } diff --git a/model/alarm.go b/model/alarm.go index b6faf47..d2f75e3 100644 --- a/model/alarm.go +++ b/model/alarm.go @@ -174,7 +174,7 @@ func (a *AlarmRepeated) FillExcepts(cfg *config.Config, db *LevelDBStorage) erro end := time.Time(*exception.End).AddDate(0, 0, 1) for t := time.Time(*exception.Start); end.After(t); t = t.AddDate(0, 0, 1) { if t.Weekday() == a.Weekday { - a.Excepts = append(a.Excepts, time.Date(t.Year(), t.Month(), t.Day(), time.Time(*a.StartTime).Hour(), time.Time(*a.StartTime).Minute(), time.Time(*a.StartTime).Second(), 0, cfg.Timezone.GetLocation())) + a.Excepts = append(a.Excepts, time.Date(t.Year(), t.Month(), t.Day(), time.Time(*a.StartTime).Hour(), time.Time(*a.StartTime).Minute(), time.Time(*a.StartTime).Second(), 0, time.Local)) t = t.AddDate(0, 0, 6) } } @@ -196,7 +196,7 @@ func (a *AlarmRepeated) GetNextOccurence(cfg *config.Config, db *LevelDBStorage) now := time.Now() - today := time.Date(now.Year(), now.Month(), now.Day(), time.Time(*a.StartTime).Hour(), time.Time(*a.StartTime).Minute(), time.Time(*a.StartTime).Second(), 0, cfg.Timezone.GetLocation()) + today := time.Date(now.Year(), now.Month(), now.Day(), time.Time(*a.StartTime).Hour(), time.Time(*a.StartTime).Minute(), time.Time(*a.StartTime).Second(), 0, time.Local) if now.After(today) { today = today.AddDate(0, 0, 1) } diff --git a/ui/nojs.go b/ui/nojs.go index 2d40706..ddcb69f 100644 --- a/ui/nojs.go +++ b/ui/nojs.go @@ -82,8 +82,8 @@ func DeclareNoJSRoutes(router *gin.Engine, cfg *config.Config, db *reveil.LevelD return } - _, offset := alarm.Zone() - alarm = alarm.Truncate(24 * time.Hour).Add(-time.Duration(offset)*time.Second + duration) + alarm = alarm.Local().Truncate(24 * time.Hour) + alarm = alarm.Add(-time.Duration(alarm.Hour())*time.Hour + duration) } if time.Now().After(alarm) {