Use system or default TZ env var
All checks were successful
continuous-integration/drone/tag Build is passing
All checks were successful
continuous-integration/drone/tag Build is passing
This commit is contained in:
parent
cbf0fcd25a
commit
2c146f5615
1
app.go
1
app.go
@ -65,7 +65,6 @@ func (app *App) Start() {
|
|||||||
Handler: app.router,
|
Handler: app.router,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Current timezone:", app.cfg.Timezone.String())
|
|
||||||
app.ResetTimer()
|
app.ResetTimer()
|
||||||
|
|
||||||
log.Printf("Ready, listening on %s\n", app.cfg.Bind)
|
log.Printf("Ready, listening on %s\n", app.cfg.Bind)
|
||||||
|
@ -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.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.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.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
|
// Others flags are declared in some other files when they need specials configurations
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ type Config struct {
|
|||||||
ActionsDir string
|
ActionsDir string
|
||||||
RoutinesDir string
|
RoutinesDir string
|
||||||
|
|
||||||
Timezone Timezone
|
|
||||||
SampleRate int
|
SampleRate int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ func (a *AlarmRepeated) FillExcepts(cfg *config.Config, db *LevelDBStorage) erro
|
|||||||
end := time.Time(*exception.End).AddDate(0, 0, 1)
|
end := time.Time(*exception.End).AddDate(0, 0, 1)
|
||||||
for t := time.Time(*exception.Start); end.After(t); t = t.AddDate(0, 0, 1) {
|
for t := time.Time(*exception.Start); end.After(t); t = t.AddDate(0, 0, 1) {
|
||||||
if t.Weekday() == a.Weekday {
|
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)
|
t = t.AddDate(0, 0, 6)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ func (a *AlarmRepeated) GetNextOccurence(cfg *config.Config, db *LevelDBStorage)
|
|||||||
|
|
||||||
now := time.Now()
|
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) {
|
if now.After(today) {
|
||||||
today = today.AddDate(0, 0, 1)
|
today = today.AddDate(0, 0, 1)
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ func DeclareNoJSRoutes(router *gin.Engine, cfg *config.Config, db *reveil.LevelD
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, offset := alarm.Zone()
|
alarm = alarm.Local().Truncate(24 * time.Hour)
|
||||||
alarm = alarm.Truncate(24 * time.Hour).Add(-time.Duration(offset)*time.Second + duration)
|
alarm = alarm.Add(-time.Duration(alarm.Hour())*time.Hour + duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Now().After(alarm) {
|
if time.Now().After(alarm) {
|
||||||
|
Loading…
Reference in New Issue
Block a user