add new func
This commit is contained in:
parent
1218887a1b
commit
b0fd8947f0
21
time_test.go
21
time_test.go
@ -195,3 +195,24 @@ func TestParseCronMax(t *testing.T) {
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
func TestPrepareCron2(t *testing.T) {
|
||||
tk := StarTimer{
|
||||
base: time.Now(),
|
||||
repeat: []*Repeats{
|
||||
{
|
||||
Every: false,
|
||||
Repeat: []Repeat{
|
||||
//{Unit: STAR_MINUTE, Value: 0},
|
||||
{Unit: STAR_HOUR, Value: 11},
|
||||
{Unit: STAR_WEEK, Value: 5}, {Unit: STAR_WEEK, Value: 6}, {Unit: STAR_WEEK, Value: 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
base := tk.base
|
||||
for i := 0; i < 10; i++ {
|
||||
base = tk.parseNextDate(base, true)
|
||||
fmt.Println(base)
|
||||
}
|
||||
}
|
||||
|
13
timer.go
13
timer.go
@ -318,10 +318,13 @@ func (t *StarTimer) parseStaticNextDate(base time.Time, r *Repeats, recall bool)
|
||||
}
|
||||
}
|
||||
}
|
||||
if target.UnixNano() == base.UnixNano() && veryDay == veryMonth && veryDay == 0 {
|
||||
target = target.Add(time.Hour * 24)
|
||||
}
|
||||
if (veryDay != 0 && target.Day() != veryDay) || (veryMonth != 0 && int(target.Month()) != veryMonth) {
|
||||
continue
|
||||
}
|
||||
if target == base && !recall {
|
||||
if target.UnixNano() == base.UnixNano() && !recall {
|
||||
continue
|
||||
}
|
||||
targets = append(targets, target)
|
||||
@ -343,8 +346,12 @@ func (t *StarTimer) parseStaticNextDate(base time.Time, r *Repeats, recall bool)
|
||||
return targets[0]
|
||||
}
|
||||
}
|
||||
nextBase := time.Date(targets[0].Year(), targets[0].Month(), targets[0].Day(), 0, 0, 0, 0, targets[0].Location())
|
||||
return t.parseStaticNextDate(nextBase.Add(time.Hour*24), r, true)
|
||||
nextBase := targets[0]
|
||||
if nextBase == base {
|
||||
nextBase = time.Date(targets[0].Year(), targets[0].Month(), targets[0].Day(), 0, 0, 0, 0, targets[0].Location())
|
||||
nextBase = nextBase.Add(time.Hour * 24)
|
||||
}
|
||||
return t.parseStaticNextDate(nextBase, r, true)
|
||||
}
|
||||
}
|
||||
if len(targets) > 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user