I needed to count the overlap of the datetime intervals. After some coding I’ve refactored the code to static class and uploaded to Github, so that others can use it too. It might save you some time 🙂
There are currently two methods. One to get the interval overlap and the other to count the interval duration.
Go ahead and check out our company GitHub. The code is pretty straight forward, so no need to explain too much.