atifaziz / NCrontab

Crontab for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when using 6 components

Franklin89 opened this issue · comments

I am getting the following exception when using: CrontabSchedule.Parse. Using Version 3.3.0

NCrontab.CrontabException: ''* * * * * *' is an invalid crontab expression. It must contain 5 components of a schedule in the sequence of minutes, hours, days, months, and days of week

A 6-field expression is an extension to the standard 5-field crontab expression. Make sure that you call the Parse method overload that accepts a ParseOptions object and that its IncludingSeconds is set to true, like this:

[Test]
public void SixPartAllTimeString()
{
Assert.AreEqual("* * * * * *", CrontabSchedule.Parse("* * * * * *", new ParseOptions { IncludingSeconds = true }).ToString());
}

Hi @atifaziz I'd consider adding this in the documentation and the exception message as I also nearly created a bug for this.
Thank you!