Compare commits

..

No commits in common. 'c59d801434844ccc20b3cc15e86cee63f550327b' and 'fc2c1a1348391a16b07bfc237c4b6046515b41c7' have entirely different histories.

@ -4,7 +4,7 @@ go 1.20
require (
b612.me/stardb v1.1.4
b612.me/startimer v0.0.0-20230529074834-557abef590fe
b612.me/startimer v0.0.1
github.com/glebarez/go-sqlite v1.21.1
)

@ -1,7 +1,7 @@
b612.me/stardb v1.1.4 h1:Ic+CwGZpDKtgHTkDJ5/1kxgEEGM9Hj5xu9i0n6CbXfs=
b612.me/stardb v1.1.4/go.mod h1:qtGEu+joEQxFESl3tse5xqiD767f6sAmHD284+Xoy48=
b612.me/startimer v0.0.0-20230529074834-557abef590fe h1:Hy9hkSPiWjWvui6kiAvIShP1ZaPNT9fVJCHq5e4tZPk=
b612.me/startimer v0.0.0-20230529074834-557abef590fe/go.mod h1:7YlIWMVBIxLObVI0Ls+CMCCVZJ+4DdTaqF2TshthZjk=
b612.me/startimer v0.0.1 h1:7Q4hzkXZR1iFSWyEoTBjUiDx1HsROIvIel3HdfhIhxo=
b612.me/startimer v0.0.1/go.mod h1:7YlIWMVBIxLObVI0Ls+CMCCVZJ+4DdTaqF2TshthZjk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY=

@ -99,7 +99,7 @@ func (r *Remind) callbackFn(task *Task) {
r.callback(*task)
}
if !task.GetTimer().IsRunning() {
go r.DeleteTask(task.ID)
r.DeleteTask(task.ID)
}
}

@ -16,30 +16,6 @@ func exists(path string) bool {
}
return err == nil
}
func TestStarDB(t *testing.T) {
var db stardb.StarDB
err := db.Open("sqlite", "./db.sqlite")
if err != nil {
t.Fatal(err)
}
var r *Remind
r, err = NewRemind(&db, func(task Task) {
fmt.Println("hello world!", time.Now(), task.ID, task.Key, task.TmrInfo, task.Msg, task.Origin)
fmt.Println(task.GetTimer().NextTimer(), task.GetTimer().IsRunning())
fmt.Println(r.ListTasks())
fmt.Println("ok")
time.Sleep(time.Second * 10)
fmt.Println(task.GetTimer().NextTimer())
})
tk, err := r.AddTask("每天下午3点52分20秒提醒我吃饭", "00", []byte{})
if err != nil {
t.Fatal(err)
}
fmt.Println(tk.GetTimer().NextTimer())
fmt.Println(r.ListTasks())
fmt.Println("hello")
time.Sleep(time.Second * 120)
}
func TestOtherDb(t *testing.T) {
var db stardb.StarDB

@ -191,13 +191,6 @@ 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,17 +26,3 @@ 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…
Cancel
Save