From 83135b3c5c4ea02e1ef1a3846922b4ac92fdab05 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 31 Aug 2013 09:00:12 -0400 Subject: [PATCH] renaming cronexpression to cronexpr --- cronexpr.go | 13 +++++++++---- cronexpr_test.go | 10 +++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cronexpr.go b/cronexpr.go index d3c3d52..5909aa1 100644 --- a/cronexpr.go +++ b/cronexpr.go @@ -1,15 +1,15 @@ /*! * Copyright 2013 Raymond Hill * - * Project: github.com/gorhill/cronexpression - * File: cronexpression.go + * Project: github.com/gorhill/cronexpr + * File: cronexpr.go * Version: 1.0 * License: GPL v3 see * */ -// Package cronexpression parses cron time expressions. -package cronexpression +// Package cronexpr parses cron time expressions. +package cronexpr /******************************************************************************/ @@ -100,6 +100,8 @@ func Parse(cronLine string) *Expression { // Given a time stamp `fromTime`, return the closest following time stamp which // matches the cron expression `expr`. The `time.Location` of the returned // time stamp is the same as `fromTime`. +// +// A nil time.Time object is returned if no matching time stamp exists. func (expr *Expression) Next(fromTime time.Time) time.Time { // Special case if fromTime.IsZero() { @@ -186,6 +188,9 @@ func (expr *Expression) Next(fromTime time.Time) time.Time { // stamps which match the cron expression `expr`. The time stamps in the // returned slice are in chronological ascending order. The `time.Location` of // the returned time stamps is the same as `fromTime`. +// +// A slice with less than `n` entries (up to zero) is returned if not +// enough existing matching time stamps which exist. func (expr *Expression) NextN(fromTime time.Time, n int) []time.Time { if n <= 0 { panic("Expression.NextN(): invalid count") diff --git a/cronexpr_test.go b/cronexpr_test.go index 3bd76fe..da84633 100644 --- a/cronexpr_test.go +++ b/cronexpr_test.go @@ -1,19 +1,19 @@ /*! * Copyright 2013 Raymond Hill * - * Project: github.com/gorhill/cronexpression - * File: cronexpression_test.go + * Project: github.com/gorhill/cronexpr + * File: cronexpr_test.go * Version: 1.0 * License: GPL v3 see * */ -package cronexpression_test +package cronexpr_test /******************************************************************************/ import ( - "cronexpression" + "cronexpr" "testing" "time" ) @@ -113,7 +113,7 @@ func TestExpressions(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.Parse(test.expr).Next(from) + next := cronexpr.Parse(test.expr).Next(from) nextstr := next.Format(test.layout) if nextstr != times.next { t.Errorf("(\"%s\").Next(\"%s\") = \"%s\", got \"%s\"", test.expr, times.from, times.next, nextstr)