Skip to content

Commit

Permalink
example for CronExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Feb 25, 2015
1 parent a42a259 commit 22e4310
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion timer/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package timer_test
import (
"fmt"
"github.com/name5566/leaf/timer"
"time"
)

func Example() {
func ExampleTimer() {
d := timer.NewDispatcher(10)

// timer 1
Expand All @@ -25,3 +26,19 @@ func Example() {
// Output:
// My name is Leaf
}

func ExampleCronExpr() {
cronExpr, err := timer.NewCronExpr("0 * * * *")
if err != nil {
return
}

fmt.Println(cronExpr.Next(time.Date(
2000, 1, 1,
20, 10, 5,
0, time.UTC,
)))

// Output:
// 2000-01-01 21:00:00 +0000 UTC
}

0 comments on commit 22e4310

Please sign in to comment.