This commit is contained in:
+5
-3
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user