From 224a974a69f3b30dc8c808df24597be1006700e2 Mon Sep 17 00:00:00 2001 From: starainrt Date: Thu, 18 May 2023 23:39:47 +0800 Subject: [PATCH] bug fix --- when/parse.go | 2 +- when/parse_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/when/parse.go b/when/parse.go index c18a786..ac749e4 100644 --- a/when/parse.go +++ b/when/parse.go @@ -137,7 +137,7 @@ func matchPeriodPattern01(base time.Time, str string) (startimer.StarTimer, erro } else { base.Add(time.Second * time.Duration(uint32(getNumbers(pts[8])))) } - } else if hour != 0 { + } else if hour != 0 || pts[7] != "" { if rpt.Every == setAsDate { rpt.Repeat = append(rpt.Repeat, startimer.Repeat{Unit: startimer.STAR_SECOND, Value: 0}) } diff --git a/when/parse_test.go b/when/parse_test.go index 57a3876..3e9d479 100644 --- a/when/parse_test.go +++ b/when/parse_test.go @@ -9,7 +9,7 @@ import ( func TestParse(t *testing.T) { for _, code := range []string{"一个小时后告诉我事情", "三个小时后爱我", "每两个小时提醒我吃饭", "每五个月零二十五天三小时25分15秒告诉我时间", "5月23日上午3点24分12秒打我", "周五上午11点提醒我", "5时25分提醒我", - "每周一到周五上午8点提醒我吃饭", "每天晚上8点提醒我吃饭", "每月16号晚上8点提醒我吃饭", "晚上8:30提醒我", "晚上八点半提醒我", "6分钟后提醒我"} { + "每周一到周五上午8点提醒我吃饭", "每天晚上8点提醒我吃饭", "每月16号晚上8点提醒我吃饭", "晚上8:30提醒我", "晚上八点半提醒我", "6分钟后提醒我", "凌晨0点半"} { a, _ := WhenWithPeriod(code) //fmt.Println(a.Repeats()[0]) fmt.Println(a.NextTimer(), a.RunCountLimit(), code)