bug fix
This commit is contained in:
parent
fc2c1a1348
commit
dfe4801421
@ -191,6 +191,13 @@ func matchPeroidPattern02(base time.Time, str string) (startimer.StarTimer, erro
|
||||
reg := regexp.MustCompile(`(每)?([周星期礼拜][周礼拜星期到1-6日天]+)+的?([上中下午夜早凌清晨傍晚里]+)?(\d{1,4}[个点时:]+)?(\d{0,4}[分半:]?钟?)?(\d{1,10}秒?钟?)?`)
|
||||
if reg.MatchString(str) {
|
||||
pts := reg.FindStringSubmatch(str)
|
||||
scs := len(strings.Split(pts[0], "周"))
|
||||
if scs > 3 {
|
||||
return startimer.StarTimer{}, errors.New("Invalid stings")
|
||||
}
|
||||
if scs == 3 && !strings.Contains(pts[0], "到") {
|
||||
return startimer.StarTimer{}, errors.New("Invalid stings")
|
||||
}
|
||||
if pts[2] != "" {
|
||||
wk := strings.ReplaceAll(pts[2], "周日", "周0")
|
||||
wk = strings.ReplaceAll(wk, "礼拜天", "周0")
|
||||
|
@ -26,3 +26,17 @@ func TestSigParse(t *testing.T) {
|
||||
fmt.Println(a.NextTimerAfterDate(time.Now().Add(time.Hour * 72)))
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalid(t *testing.T) {
|
||||
for k, code := range []string{"每周一周二周四中午11点30分提醒我带夹子和雨伞"} {
|
||||
a, err := WhenWithPeriod(code)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
//fmt.Println(a.Repeats()[0])
|
||||
fmt.Println(a.ExportRepeats())
|
||||
fmt.Println(a.NextTimer(), a.RunCountLimit(), code, k)
|
||||
fmt.Println(a.NextTimerAfterDate(time.Now().Add(time.Hour * 72)))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user