u 3 years ago
parent
commit
83f0683ebd
  1. 12
      core.go

12
core.go

@ -1,12 +1,10 @@
package time_arrow
import (
"encoding/json"
"fmt"
"log"
"sort"
"strings"
"sync"
"time"
"github.com/google/uuid"
@ -119,7 +117,7 @@ func isInDayOfMonth(t time.Time, ta TimeArrow) bool {
return false
}
var isInTimeOfDayCacheBool sync.Map
// var isInTimeOfDayCacheBool sync.Map
func isInTimeOfDay(t time.Time, ta TimeArrow) bool {
@ -130,8 +128,8 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool {
tfdate := t.Format("2006-01-02 15:04:05")
var err error
tmp, err := json.Marshal(ta.TimesOnDay)
mainKey := fmt.Sprintf("[%s][%s]", tfdate, string(tmp))
// tmp, err := json.Marshal(ta.TimesOnDay)
// mainKey := fmt.Sprintf("[%s][%s]", tfdate, string(tmp))
// value, ok := isInTimeOfDayCacheBool.Load(mainKey)
// if ok && err == nil {
@ -199,11 +197,11 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool {
}
if (t.After(startTime) || t.Equal(startTime)) && t.Before(endTime) {
isInTimeOfDayCacheBool.Store(mainKey, 3)
// isInTimeOfDayCacheBool.Store(mainKey, 3)
return true
}
}
isInTimeOfDayCacheBool.Store(mainKey, 4)
// isInTimeOfDayCacheBool.Store(mainKey, 4)
return false
}

Loading…
Cancel
Save