HangfireIO / HangfireIO/Cronos

ToString creates unparsable string in case CronFormat.IncludeSeconds is set

Open
#72 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
137
Avg merge
5d 11h
Merged PRs (30d)
1

Description

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);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.