Skip to content

Instantly share code, notes, and snippets.

@dthphuong
Created November 18, 2020 03:23
Show Gist options
  • Save dthphuong/6b4ba554d5ba4c73da32d3c8019dd7b5 to your computer and use it in GitHub Desktop.
Save dthphuong/6b4ba554d5ba4c73da32d3c8019dd7b5 to your computer and use it in GitHub Desktop.
Check DateTime Overlap
startA                        endA
  |------- DateRange A --------|                    _ 
  _                          |-----Date Range B ----|
                           startB                  endB

Idea: DateRangesOverlap = max(startA, startB) < min(endA, endB) Code:

(startA > startB ? startA: startB) <= (endA < endB ? endA: endB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment