|
|
@ -1,6 +1,7 @@ |
|
|
|
package time_arrow |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"log" |
|
|
|
"sort" |
|
|
@ -128,19 +129,21 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool { |
|
|
|
|
|
|
|
tfdate := t.Format("2006-01-02") |
|
|
|
|
|
|
|
mainKey := fmt.Sprintf("[%s][%s]", tfdate, strings.Join(ta.TimesOnDay, "|")) |
|
|
|
// value, ok := isInTimeOfDayCacheBool.Load(mainKey)
|
|
|
|
// if ok {
|
|
|
|
// ret, ok := value.(int)
|
|
|
|
// if ok {
|
|
|
|
// if ret == 1 {
|
|
|
|
// return true
|
|
|
|
// }
|
|
|
|
// if ret == 2 {
|
|
|
|
// return false
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
tmp, _ := json.Marshal(ta.TimesOnDay) |
|
|
|
mainKey := fmt.Sprintf("[%s][%s]", tfdate, string(tmp)) |
|
|
|
|
|
|
|
value, ok := isInTimeOfDayCacheBool.Load(mainKey) |
|
|
|
if ok { |
|
|
|
ret, ok := value.(int) |
|
|
|
if ok { |
|
|
|
if ret == 1 { |
|
|
|
return true |
|
|
|
} |
|
|
|
if ret == 2 { |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
parseInLocationCache := map[string]time.Time{} |
|
|
|
var err error |
|
|
@ -158,7 +161,7 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool { |
|
|
|
|
|
|
|
startTimeKey := fmt.Sprintf("%s %s", tfdate, start) |
|
|
|
startTime, ok := parseInLocationCache[startTimeKey] |
|
|
|
if false && !ok { |
|
|
|
if !ok { |
|
|
|
startTime, err = time.ParseInLocation("2006-01-02 15:04:05", startTimeKey, time.Local) |
|
|
|
parseInLocationCache[startTimeKey] = startTime |
|
|
|
if err != nil { |
|
|
@ -178,7 +181,7 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool { |
|
|
|
|
|
|
|
endTimeKey := fmt.Sprintf("%s %s", tfdate, end) |
|
|
|
endTime, ok := parseInLocationCache[endTimeKey] |
|
|
|
if false && !ok { |
|
|
|
if !ok { |
|
|
|
endTime, err = time.ParseInLocation("2006-01-02 15:04:05", endTimeKey, time.Local) |
|
|
|
parseInLocationCache[endTimeKey] = endTime |
|
|
|
if err != nil { |
|
|
|