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
974
stars
114
forks
source link
ToString creates unparsable string in case CronFormat.IncludeSeconds is set #72
I am using a 3rd party lib that uses Cronos for handling cron expressions. This lib always uses CronFormat.IncludeSeconds internally so if I want to run sth. every minute I need need to use 0 * * * * *.
This is no problem in the first place, the first call to CronExpression.Parse(expression, CronFormat.IncludeSeconds) omits the 0 and returns if ToString is called * * * * * if this is used later to call CronExpression.Parse with CronFromat.IncludeSeconds an exception is thrown.
This behaviour was introduced with the fix for https://github.com/HangfireIO/Cronos/issues/15
I agree to the suggestion that was made, in some way it should be memorized that the initial expression was created explicitly with CronFormat.IncludeSeconds.
The code to reproduce this behavior is more then simple:
using Cronos;
const string expression = "0 1 * * * *";
var cronExpression = CronExpression.Parse(expression, CronFormat.IncludeSeconds);
Console.WriteLine(cronExpression.ToString());
CronExpression.Parse(cronExpression.ToString(), CronFormat.IncludeSeconds);
I am using a 3rd party lib that uses Cronos for handling cron expressions. This lib always uses
CronFormat.IncludeSeconds
internally so if I want to run sth. every minute I need need to use0 * * * * *
. This is no problem in the first place, the first call toCronExpression.Parse(expression, CronFormat.IncludeSeconds)
omits the 0 and returns if ToString is called* * * * *
if this is used later to callCronExpression.Parse
withCronFromat.IncludeSeconds
an exception is thrown.This behaviour was introduced with the fix for https://github.com/HangfireIO/Cronos/issues/15 I agree to the suggestion that was made, in some way it should be memorized that the initial expression was created explicitly with
CronFormat.IncludeSeconds
.The code to reproduce this behavior is more then simple: