diff --git a/README.md b/README.md index ad81ffb..b8b6765 100644 --- a/README.md +++ b/README.md @@ -82,11 +82,11 @@ Import the library: Simplest way: - nextTime := cronexpression.NextTimeFromString("0 0 29 2 *", time.Now()) + nextTime := cronexpression.NextTime("0 0 29 2 *", time.Now()) Assuming `time.Now()` is "2013-08-29 09:28:00", then `nextTime` will be "2016-02-29 00:00:00". -If you need to reuse many times a cron expression in your code, it is more efficient +If you need to reuse many times the same cron expression in your code, it is more efficient to create a `CronExpression` object once and keep a copy of it for reuse: cronexpr := cronexpression.NewCronExpression("0 0 29 2 *") @@ -95,11 +95,11 @@ to create a `CronExpression` object once and keep a copy of it for reuse: Use `cronexpression.NoMatch()` to find out whether a valid time was returned. For example, - cronexpression.NoMatch(cronexpression.NextTimeFromString("* * * * * 1980", time.Now())) + cronexpression.NoMatch(cronexpression.NextTime("* * * * * 1980", time.Now())) will return `true`, whereas - cronexpression.NoMatch(cronexpression.NextTimeFromString("* * * * * 2050", time.Now())) + cronexpression.NoMatch(cronexpression.NextTime("* * * * * 2050", time.Now())) will return `false` (as of 2013-08-29...) diff --git a/cronexpression.go b/cronexpression.go index 117b14f..a8f88bf 100644 --- a/cronexpression.go +++ b/cronexpression.go @@ -106,7 +106,7 @@ func NewCronExpression(cronLine string) *CronExpression { // // If the same cron expression must be used repeatedly, it is better to use // NewCronExpression() in order to avoid overhead of cron expression parsing. -func NextTimeFromString(cronLine string, fromTime time.Time) time.Time { +func NextTime(cronLine string, fromTime time.Time) time.Time { cronexpr := NewCronExpression(cronLine) return cronexpr.NextTime(fromTime) } @@ -119,7 +119,7 @@ func NextTimeFromString(cronLine string, fromTime time.Time) time.Time { // // If the same cron expression must be used repeatedly, it is better to use // NewCronExpression() in order to avoid overhead of cron expression parsing. -func NextTimeNFromString(cronLine string, fromTime time.Time, n int) []time.Time { +func NextTimeN(cronLine string, fromTime time.Time, n int) []time.Time { cronexpr := NewCronExpression(cronLine) return cronexpr.NextTimeN(fromTime, n) } diff --git a/cronexpression_test.go b/cronexpression_test.go index 7b73bc5..451b09b 100644 --- a/cronexpression_test.go +++ b/cronexpression_test.go @@ -113,7 +113,7 @@ func TestCronExpressions(t *testing.T) { for _, test := range crontests { for _, times := range test.times { from, _ := time.Parse("2006-01-02 15:04:05", times.from) - next := cronexpression.NextTimeFromString(test.expr, from) + next := cronexpression.NextTime(test.expr, from) nextstr := next.Format(test.layout) if nextstr != times.next { t.Errorf("(\"%s\").NextTime(\"%s\") = \"%s\", got \"%s\"", test.expr, times.from, times.next, nextstr)