bug fix
This commit is contained in:
parent
224a974a69
commit
74df3983a0
@ -179,7 +179,7 @@ func matchPeriodPattern01(base time.Time, str string) (startimer.StarTimer, erro
|
|||||||
func matchPeroidPattern02(base time.Time, str string) (startimer.StarTimer, error) {
|
func matchPeroidPattern02(base time.Time, str string) (startimer.StarTimer, error) {
|
||||||
str = transChn(str)
|
str = transChn(str)
|
||||||
var rpt startimer.Repeats
|
var rpt startimer.Repeats
|
||||||
reg := regexp.MustCompile(`(每)?([周星期礼拜][周礼拜星期到1-6日天]+)+的?([上中下午夜早凌清晨傍晚里]+)?(\d{1,4}[个点时:]+)?(\d{1,4}[分:])?(\d{1,10}秒?)?`)
|
reg := regexp.MustCompile(`(每)?([周星期礼拜][周礼拜星期到1-6日天]+)+的?([上中下午夜早凌清晨傍晚里]+)?(\d{1,4}[个点时:]+)?(\d{0,4}[分半:]?钟?)?(\d{1,10}秒?钟?)?`)
|
||||||
if reg.MatchString(str) {
|
if reg.MatchString(str) {
|
||||||
pts := reg.FindStringSubmatch(str)
|
pts := reg.FindStringSubmatch(str)
|
||||||
if pts[2] != "" {
|
if pts[2] != "" {
|
||||||
@ -236,6 +236,9 @@ func matchPeroidPattern02(base time.Time, str string) (startimer.StarTimer, erro
|
|||||||
rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_HOUR, Value: hour})
|
rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_HOUR, Value: hour})
|
||||||
}
|
}
|
||||||
if pts[5] != "" {
|
if pts[5] != "" {
|
||||||
|
if pts[5] == "半" {
|
||||||
|
pts[5] = "30"
|
||||||
|
}
|
||||||
rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_MINUTE, Value: uint32(getNumbers(pts[5]))})
|
rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_MINUTE, Value: uint32(getNumbers(pts[5]))})
|
||||||
} else if hour != 0 {
|
} else if hour != 0 {
|
||||||
rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_MINUTE, Value: 0})
|
rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_MINUTE, Value: 0})
|
||||||
|
@ -18,7 +18,7 @@ func TestParse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSigParse(t *testing.T) {
|
func TestSigParse(t *testing.T) {
|
||||||
for _, code := range []string{"6分钟后提醒我"} {
|
for _, code := range []string{"每周一到周五下午10:20提醒我"} {
|
||||||
a, _ := WhenWithPeriod(code)
|
a, _ := WhenWithPeriod(code)
|
||||||
//fmt.Println(a.Repeats()[0])
|
//fmt.Println(a.Repeats()[0])
|
||||||
fmt.Println(a.NextTimer(), a.RunCountLimit(), code)
|
fmt.Println(a.NextTimer(), a.RunCountLimit(), code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user