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

CronExpression.IsSatisfiedBy returns false when the DateTime that's being checked is during the hour of the local DST change #2156

Open
nikolaziv99 opened this issue Oct 9, 2023 · 0 comments

Comments

@nikolaziv99
Copy link

nikolaziv99 commented Oct 9, 2023

When trying to find the first DateTime in the timespan that doesn't match the provided cron expression using the CronExpression.IsSatisfiedBy method, the evaluation returns a false negative result when it stumbles upon the hour when the local DST is being changed. In my case, I used the cron expression which should be valid for every second in the month of October, so * * * ? 10 * *. When it gets to October 29th at 1AM UTC, it returns a false result, even though it should be true because it's still October.

Version used

Quartz.NET 3.7.0

To Reproduce

DateTime october1st = new DateTime(2023, 10, 01).ToUniversalTime();
DateTimeOffset? currentDateTime = new DateTimeOffset(october1st);

var dateIncrement = october1st;

while (dateIncrement < october1st.AddMonths(2))
{
    var standbyCronExpression = new CronExpression("* * * ? 10 * *");

    var matched = standbyCronExpression.IsSatisfiedBy(currentDateTime.Value);

    if (matched)
    {
        dateIncrement = dateIncrement.AddMinutes(1);
        currentDateTime = dateIncrement.ToUniversalTime();
    }
    else
    {
        Console.WriteLine("Not matched! " + currentDateTime.Value);
        Console.ReadKey();
    }
}

Expected behavior

The expected behavior in this case would be to get this output " Not matched! 31.10.2023. 23:00:00 +00:00 " which is equivalent to 01.11.2023. 00:00:00 in my local time zone (GMT+1), but instead I get Not matched! 29.10.2023. 01:00:00 +00:00.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant