Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandezja/61f4ded30ffc1edd419f77a7ed887add to your computer and use it in GitHub Desktop.
Save fernandezja/61f4ded30ffc1edd419f77a7ed887add to your computer and use it in GitHub Desktop.
TimeSpan Extensions Method IsBetween
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