HangfireIO / Cronos

A fully-featured .NET library for working with Cron expressions. Built with time zones in mind and intuitively handles daylight saving time transitions
MIT License
1.01k stars 118 forks source link

Cronos.CronFormatException: "Unexpected character '*'." #56

Closed VovaGul closed 1 year ago

VovaGul commented 1 year ago

expression "0 0 4 ? * * *" generated on site

CronExpression.Parse("0 0 4 ? * * *", CronFormat.Standard) \\ Cronos.CronFormatException: "Unexpected character '*'."
CronExpression.Parse("0 0 4 ? * * *", CronFormat.IncludeSeconds) \\ Cronos.CronFormatException: "Unexpected character '*'."

why can't it be parsed?

Cronos 0.7.1

VovaGul commented 1 year ago

0 0 4 * * * works.

I don't know why it works the way it does. It would be nice if something like this was taken into account or was described somewhere.

mattheys commented 1 year ago

It says at the top of that website that it generates Quartz cron expressions, these appear to have 7 parts. Standard expressions have 5 and Cronos supports an options 6th for seconds. Quartz seems to support a year variable which standard cron doesn't.

I just noticed in the readme it explicitly says that the year field is not supported in Quartz.Net expressions.

VovaGul commented 1 year ago

Understood. Thanks for the answer!