changes as per #5

This commit is contained in:
gorhill
2013-09-02 09:25:49 -04:00
parent 4f0ef12848
commit 5442b2bfef
4 changed files with 43 additions and 19 deletions

View File

@@ -45,11 +45,12 @@ type Expression struct {
/******************************************************************************/
// Parse returns a new Expression pointer. It expects a well-formed cron expression.
// If a malformed cron expression is supplied, the result is undefined. See
// <https://github.com/gorhill/cronexpr#implementation> for documentation
// about what is a well-formed cron expression from this library point of view.
func Parse(cronLine string) *Expression {
// MustParse returns a new Expression pointer. It expects a well-formed cron
// expression. If a malformed cron expression is supplied, it will `panic`.
// See <https://github.com/gorhill/cronexpr#implementation> for documentation
// about what is a well-formed cron expression from this library's point of
// view.
func MustParse(cronLine string) *Expression {
cronLineNormalized := cronNormalize(cronLine)
// Split into fields
@@ -73,7 +74,7 @@ func Parse(cronLine string) *Expression {
// At this point, we should have at least 7 fields. Fields beyond the
// seventh one, if any, are ignored.
if len(cronFields) < 7 {
panic("Malformed cron expression\n")
panic("MustParse(): Not enough fields in the cron time expression\n")
}
// Generic parser can be used for most fields