Created
June 1, 2022 00:25
-
-
Save fernandezja/61f4ded30ffc1edd419f77a7ed887add to your computer and use it in GitHub Desktop.
TimeSpan Extensions Method IsBetween
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class TimeSpanExtensions | |
{ | |
public static bool IsBetween(this TimeSpan target, TimeSpan start, TimeSpan end) | |
{ | |
if (target == start) return true; | |
if (target == end) return true; | |
if (start <= end) | |
return (target >= start && target <= end); | |
else | |
return !(target >= end && target <= start); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment