Skip to content

Both GetNextOccurance and GetPreviousOccurance throw exceptions when value is out of bounds #93

@DevJasperNL

Description

@DevJasperNL

This:

using Cronos;

var expression = CronExpression.Parse("0 0 * * *");
// Throws exception:
expression.GetNextOccurrence(DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc));

And also this:

using Cronos;

var expression = CronExpression.Parse("42 37 13 * * *", CronFormat.IncludeSeconds);
var dateTime = DateTime.SpecifyKind(DateTime.MinValue + new TimeSpan(0, 13, 37, 42), DateTimeKind.Utc);

// Throws exception:
expression.GetPreviousOccurrence(dateTime);

Both throw:
System.ArgumentOutOfRangeException: 'Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. (Parameter 'ticks')'

Expected:
null

@odinserj

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions