From 2f36124d9eea5415041b77ee658d3a21a361a623 Mon Sep 17 00:00:00 2001 From: lynxzp Date: Tue, 4 Jan 2022 08:50:11 +0200 Subject: [PATCH] fix select shift --- collector/sources/pkg/shift/shift.go | 2 +- collector/sources/pkg/time/time.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/collector/sources/pkg/shift/shift.go b/collector/sources/pkg/shift/shift.go index e5cd10e..be51e21 100644 --- a/collector/sources/pkg/shift/shift.go +++ b/collector/sources/pkg/shift/shift.go @@ -38,7 +38,7 @@ func GetCurrentShift() int { // return 3 //} //return 0 - t := time.Time{} + t := time.Now() for i := range config.Cfg.Shifts { if t.AfterOrEqual(config.Cfg.Shifts[i].Start) && t.BeforeOrEqual(config.Cfg.Shifts[i].Finish) { return config.Cfg.Shifts[i].Number diff --git a/collector/sources/pkg/time/time.go b/collector/sources/pkg/time/time.go index 7ab4fae..14b8585 100644 --- a/collector/sources/pkg/time/time.go +++ b/collector/sources/pkg/time/time.go @@ -3,6 +3,7 @@ package time import ( "log" "strconv" + systemT "time" ) type Time struct { @@ -49,3 +50,11 @@ func (t1 *Time) AfterOrEqual(t2 Time) bool { } return false } + +func Now() Time { + ownT := Time{} + sysT := systemT.Now() + ownT.hours = sysT.Hour() + ownT.minutes = sysT.Minute() + return ownT +}