Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# TimeSpan with Exclusions

I know this is probably not possible but off hand does anyone know if there are any shortcuts or mechanisms within .NET to allow me to do this.

I have a 'Diary'

9AM - 5PM

Inside this diary I have events or 'Appointments'

10AM - 12PM - Appointment 1
1PM - 1:30PM - Appointment 2

What I am asking for is there a tool that I can invert the diary to give me free spaces outside of these Appointments.

E.g. It would return me a list of

9AM - 10AM
12PM - 1PM
1:30PM - 5PM

So that I can then use within my program.

Any Ideas?

like image 773
TheMonkeyMan Avatar asked Feb 16 '23 06:02

TheMonkeyMan


1 Answers

You might want to check this CodeProject article: Time Period Library for .NET, specifically the TimeGapCalculator example.

like image 150
Groo Avatar answered Feb 17 '23 19:02

Groo