Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
934a306bc9 | ||
|
|
b090cb86a5 |
@@ -223,11 +223,8 @@ func (ntg NTGVision) SearchZips(zips []string) ([]Job, error) {
|
|||||||
|
|
||||||
func (ntg NTGVision) workingHours(now time.Time) bool {
|
func (ntg NTGVision) workingHours(now time.Time) bool {
|
||||||
// TODO assert M-F 9-4 EST
|
// TODO assert M-F 9-4 EST
|
||||||
location, err := time.LoadLocation("EST")
|
now = now.In(time.FixedZone("EST", -5*60*60))
|
||||||
if err != nil {
|
logtr.Debugf("ntg.workingHours: %s: weekday=%v (sun=%v, sat=%v), hour=%v (ok=9..16)", now.String(), now.Weekday(), time.Sunday, time.Saturday, now.Hour())
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
now = now.In(location)
|
|
||||||
switch now.Weekday() {
|
switch now.Weekday() {
|
||||||
case time.Sunday, time.Saturday:
|
case time.Sunday, time.Saturday:
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import (
|
|||||||
|
|
||||||
func TestWorkingHoursNTG(t *testing.T) {
|
func TestWorkingHoursNTG(t *testing.T) {
|
||||||
ntg := NTGVision{}
|
ntg := NTGVision{}
|
||||||
if !ntg.workingHours(time.Date(2022, 1, 27, 12, 0, 0, 0, time.Local)) {
|
if !ntg.workingHours(time.Date(2022, 1, 27, 12, 0, 0, 0, time.FixedZone("MST", -7*60*60))) {
|
||||||
t.Fatal("noon MST not ok")
|
t.Fatal("noon MST not ok")
|
||||||
}
|
}
|
||||||
if ntg.workingHours(time.Date(2022, 1, 27, 23, 0, 0, 0, time.Local)) {
|
if ntg.workingHours(time.Date(2022, 1, 27, 23, 0, 0, 0, time.FixedZone("MST", -7*60*60))) {
|
||||||
t.Fatal("midnight MST ok")
|
t.Fatal("midnight MST ok")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user