From c805a2ea5cced8072c53f67f1dceb75e353221ef Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 30 Aug 2013 08:12:14 -0400 Subject: [PATCH] Changed NextTimeFromCronString() to NextTimeFromString() --- README.md | 6 +++--- cronexpression.go | 8 ++++---- cronexpression_test.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b5ff827..ad81ffb 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Import the library: Simplest way: - nextTime := cronexpression.NextTimeFromCronString("0 0 29 2 *", time.Now()) + nextTime := cronexpression.NextTimeFromString("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". @@ -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.NextTimeFromCronString("* * * * * 1980", time.Now())) + cronexpression.NoMatch(cronexpression.NextTimeFromString("* * * * * 1980", time.Now())) will return `true`, whereas - cronexpression.NoMatch(cronexpression.NextTimeFromCronString("* * * * * 2050", time.Now())) + cronexpression.NoMatch(cronexpression.NextTimeFromString("* * * * * 2050", time.Now())) will return `false` (as of 2013-08-29...) diff --git a/cronexpression.go b/cronexpression.go index 304a985..117b14f 100644 --- a/cronexpression.go +++ b/cronexpression.go @@ -100,26 +100,26 @@ func NewCronExpression(cronLine string) *CronExpression { /******************************************************************************/ -// NextTimeFromCronString() returns the time stamp following fromTime which +// NextTimeFromString() returns the time stamp following fromTime which // satisfies the cron expression cronLine. If no matching time stamp is found, // using NoMatch() with the returned time stamp as argument will return true. // // 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 NextTimeFromCronString(cronLine string, fromTime time.Time) time.Time { +func NextTimeFromString(cronLine string, fromTime time.Time) time.Time { cronexpr := NewCronExpression(cronLine) return cronexpr.NextTime(fromTime) } /******************************************************************************/ -// NextTimeNFromCronString() returns the n time stamps following fromTime which +// NextTimeNFromString() returns the n time stamps following fromTime which // satisfy the cron expression cronLine. An empty list is returned if // there is no matching time stamp. // // 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 NextTimeNFromCronString(cronLine string, fromTime time.Time, n int) []time.Time { +func NextTimeNFromString(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 5501baa..7b73bc5 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.NextTimeFromCronString(test.expr, from) + next := cronexpression.NextTimeFromString(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)