Skip to content

Commit

Permalink
chore: remove unnecessary else branch in date constraint, this is now…
Browse files Browse the repository at this point in the history
… redundant
  • Loading branch information
sighphyre committed Oct 25, 2024
1 parent e7df774 commit 5aaf8b0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/Unleash/Strategies/Constraints/DateConstraintOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@ public bool Evaluate(Constraint constraint, UnleashContext context)

var contextValue = context.GetByName(constraint.ContextName);
DateTimeOffset? contextDate;
if (!string.IsNullOrWhiteSpace(contextValue))
{
if (!DateTimeOffset.TryParse(contextValue, out var date))
return false;
else
contextDate = date;
}

if (!DateTimeOffset.TryParse(contextValue, out var date))
return false;
else
{
contextDate = context.CurrentTime;
if (!contextDate.HasValue)
return false;
}
contextDate = date;

if (constraint.Inverted)
return !Eval(constraint.Operator, constraintDate, contextDate.Value);
Expand Down

0 comments on commit 5aaf8b0

Please sign in to comment.