HangfireIO / HangfireIO/Cronos

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

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

Description

This:
```cs
using Cronos;

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

And also this:
```cs
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

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.