From 5aaf8b0845452d01b5cf12553fd4bc7c4dd7b52d Mon Sep 17 00:00:00 2001 From: Simon Hornby Date: Fri, 25 Oct 2024 09:39:05 +0200 Subject: [PATCH] chore: remove unnecessary else branch in date constraint, this is now redundant --- .../Constraints/DateConstraintOperator.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Unleash/Strategies/Constraints/DateConstraintOperator.cs b/src/Unleash/Strategies/Constraints/DateConstraintOperator.cs index daee1a94..8c405a68 100644 --- a/src/Unleash/Strategies/Constraints/DateConstraintOperator.cs +++ b/src/Unleash/Strategies/Constraints/DateConstraintOperator.cs @@ -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);