Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToString creates unparsable string in case CronFormat.IncludeSeconds is set #72

Open
codingWombat opened this issue Jun 23, 2024 · 0 comments

Comments

@codingWombat
Copy link

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 #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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant