|
@ -9,6 +9,8 @@ import ( |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var TimeOfDayTimeZone = time.UTC |
|
|
|
|
|
|
|
|
type TimeOfDay int |
|
|
type TimeOfDay int |
|
|
|
|
|
|
|
|
func (t *TimeOfDay) UnmarshalJSON(v []byte) error { |
|
|
func (t *TimeOfDay) UnmarshalJSON(v []byte) error { |
|
@ -29,7 +31,6 @@ func (t *TimeOfDay) UnmarshalJSON(v []byte) error { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t2, err := ParseTimeOfDay(str) |
|
|
t2, err := ParseTimeOfDay(str) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
@ -82,11 +83,12 @@ func (t TimeOfDay) IsBetween(from TimeOfDay, to TimeOfDay) bool { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func CurrentTimeOfDay() TimeOfDay { |
|
|
func CurrentTimeOfDay() TimeOfDay { |
|
|
return TimeOfDayFromDate(time.Now().Local()) |
|
|
|
|
|
|
|
|
return TimeOfDayFromDate(time.Now().In(TimeOfDayTimeZone)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func TimeOfDayFromDate(date time.Time) TimeOfDay { |
|
|
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 { |
|
|
func NewTimeOfDay(hours, minutes, seconds int) TimeOfDay { |
|
|