Location, location, location.
continuous-integration/drone Build is passing

This commit is contained in:
Stian Fredrik Aune
2022-01-21 19:26:06 +01:00
parent 15536c6078
commit a08685c3cd
3 changed files with 27 additions and 5 deletions
+5 -3
View File
@@ -9,6 +9,8 @@ import (
"time"
)
var TimeOfDayTimeZone = time.UTC
type TimeOfDay int
func (t *TimeOfDay) UnmarshalJSON(v []byte) error {
@@ -29,7 +31,6 @@ func (t *TimeOfDay) UnmarshalJSON(v []byte) error {
}
}
t2, err := ParseTimeOfDay(str)
if err != nil {
return err
@@ -82,11 +83,12 @@ func (t TimeOfDay) IsBetween(from TimeOfDay, to TimeOfDay) bool {
}
func CurrentTimeOfDay() TimeOfDay {
return TimeOfDayFromDate(time.Now().Local())
return TimeOfDayFromDate(time.Now().In(TimeOfDayTimeZone))
}
func TimeOfDayFromDate(date time.Time) TimeOfDay {
return NewTimeOfDay(date.Hour(), date.Minute(), date.Second())
localDate := date.In(TimeOfDayTimeZone)
return NewTimeOfDay(localDate.Hour(), localDate.Minute(), localDate.Second())
}
func NewTimeOfDay(hours, minutes, seconds int) TimeOfDay {