|
|
|
@ -7,7 +7,7 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestTimer(t *testing.T) {
|
|
|
|
|
tk:= StarTimer{
|
|
|
|
|
tk := StarTimer{
|
|
|
|
|
base: time.Now(),
|
|
|
|
|
repeat: []*Repeats{
|
|
|
|
|
{
|
|
|
|
@ -17,6 +17,10 @@ func TestTimer(t *testing.T) {
|
|
|
|
|
Unit: STAR_MINUTE,
|
|
|
|
|
Value: 7,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Unit: STAR_HOUR,
|
|
|
|
|
Value: 19,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Unit: STAR_HOUR,
|
|
|
|
|
Value: 18,
|
|
|
|
@ -47,9 +51,103 @@ func TestTimer(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
base:=tk.base
|
|
|
|
|
for i:=0;i<10;i++{
|
|
|
|
|
base=tk.parseNextDate(base)
|
|
|
|
|
base := tk.base
|
|
|
|
|
for i := 0; i < 50; i++ {
|
|
|
|
|
base = tk.parseNextDate(base, true)
|
|
|
|
|
fmt.Println(base)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPrepareCronMax(t *testing.T) {
|
|
|
|
|
var rpt = new(Repeats)
|
|
|
|
|
for i := 0; i < 60; i++ {
|
|
|
|
|
if i%2 != 0 {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
rpt.Repeat = append(rpt.Repeat, Repeat{
|
|
|
|
|
Unit: STAR_SECOND,
|
|
|
|
|
Value: uint32(i),
|
|
|
|
|
}, Repeat{
|
|
|
|
|
Unit: STAR_MINUTE,
|
|
|
|
|
Value: uint32(i),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
for i := 0; i < 24; i++ {
|
|
|
|
|
rpt.Repeat = append(rpt.Repeat, Repeat{
|
|
|
|
|
Unit: STAR_HOUR,
|
|
|
|
|
Value: uint32(i),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
for i := 1; i < 7; i++ {
|
|
|
|
|
rpt.Repeat = append(rpt.Repeat, Repeat{
|
|
|
|
|
Unit: STAR_MONTH,
|
|
|
|
|
Value: uint32(i),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
tk := StarTimer{
|
|
|
|
|
base: time.Now(),
|
|
|
|
|
repeat: []*Repeats{
|
|
|
|
|
{
|
|
|
|
|
Every: false,
|
|
|
|
|
Repeat: rpt.Repeat,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
base := tk.base
|
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
|
base = tk.parseNextDate(base, true)
|
|
|
|
|
fmt.Println(base)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPrepareCron(t *testing.T) {
|
|
|
|
|
tk := StarTimer{
|
|
|
|
|
base: time.Now(),
|
|
|
|
|
repeat: []*Repeats{
|
|
|
|
|
{
|
|
|
|
|
//*/3,5,6 */2,4,6 6 1-5 5
|
|
|
|
|
Every: false,
|
|
|
|
|
Repeat: []Repeat{
|
|
|
|
|
{Unit: STAR_MINUTE, Value: 0}, {Unit: STAR_MINUTE, Value: 3}, {Unit: STAR_MINUTE, Value: 6}, {Unit: STAR_MINUTE, Value: 9}, {Unit: STAR_MINUTE, Value: 12}, {Unit: STAR_MINUTE, Value: 15}, {Unit: STAR_MINUTE, Value: 18}, {Unit: STAR_MINUTE, Value: 21},
|
|
|
|
|
{Unit: STAR_MINUTE, Value: 24}, {Unit: STAR_MINUTE, Value: 27}, {Unit: STAR_MINUTE, Value: 30}, {Unit: STAR_MINUTE, Value: 33}, {Unit: STAR_MINUTE, Value: 36}, {Unit: STAR_MINUTE, Value: 39}, {Unit: STAR_MINUTE, Value: 42}, {Unit: STAR_MINUTE, Value: 45},
|
|
|
|
|
{Unit: STAR_MINUTE, Value: 48}, {Unit: STAR_MINUTE, Value: 51}, {Unit: STAR_MINUTE, Value: 54}, {Unit: STAR_MINUTE, Value: 57}, {Unit: STAR_MINUTE, Value: 5},
|
|
|
|
|
{Unit: STAR_HOUR, Value: 2}, {Unit: STAR_HOUR, Value: 4}, {Unit: STAR_HOUR, Value: 6}, {Unit: STAR_HOUR, Value: 8}, {Unit: STAR_HOUR, Value: 10}, {Unit: STAR_HOUR, Value: 12}, {Unit: STAR_HOUR, Value: 14}, {Unit: STAR_HOUR, Value: 16}, {Unit: STAR_HOUR, Value: 18}, {Unit: STAR_HOUR, Value: 20}, {Unit: STAR_HOUR, Value: 22}, {Unit: STAR_HOUR, Value: 0},
|
|
|
|
|
{Unit: STAR_DAY, Value: 6},
|
|
|
|
|
{Unit: STAR_MONTH, Value: 1}, {Unit: STAR_MONTH, Value: 2}, {Unit: STAR_MONTH, Value: 3}, {Unit: STAR_MONTH, Value: 4}, {Unit: STAR_MONTH, Value: 5},
|
|
|
|
|
{Unit: STAR_WEEK, Value: 5},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
base := tk.base
|
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
|
base = tk.parseNextDate(base, true)
|
|
|
|
|
fmt.Println(base)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPrepareCronSimple(t *testing.T) {
|
|
|
|
|
tk := StarTimer{
|
|
|
|
|
base: time.Now(),
|
|
|
|
|
repeat: []*Repeats{
|
|
|
|
|
{
|
|
|
|
|
Every: false,
|
|
|
|
|
Repeat: []Repeat{
|
|
|
|
|
{Unit: STAR_MINUTE, Value: 0}, {Unit: STAR_MINUTE, Value: 3}, {Unit: STAR_MINUTE, Value: 6},
|
|
|
|
|
{Unit: STAR_HOUR, Value: 2}, {Unit: STAR_HOUR, Value: 4}, {Unit: STAR_HOUR, Value: 6},
|
|
|
|
|
{Unit: STAR_DAY, Value: 6},
|
|
|
|
|
{Unit: STAR_MONTH, Value: 1}, {Unit: STAR_MONTH, Value: 5},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
base := tk.base
|
|
|
|
|
for i := 0; i < 1; i++ {
|
|
|
|
|
base = tk.parseNextDate(base, true)
|
|
|
|
|
fmt.Println(base)
|
|
|
|
|
fmt.Println("")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|