I have a list of objects for each day of week, that store working and not working hours for each day of week.
public class Schedule
{
public bool IsOn { get; set; }
public DayOfWeek DayOfWeek { get; set; }
public short TimeFrom { get; set; } // store time as amount of minutes since start of day
public short TimeTo { get; set; } // store time as amount of minutes since start of day
}
So what I'm trying to get is time range for each day of week. For example we have 2 items for Monday
new Schedule() { IsOn = true, DayOfWeek = DayOfWeek.Moday, TimeFrom = 540, TimeTo = 1080 }
new Schedule() { IsOn = false, DayOfWeek = DayOfWeek.Moday, TimeFrom = 780, TimeTo = 840 }
I need to show this on UI as: Monday: 9:00-13:00; 14:00-18:00
UPDATE
Main thing I want to know is algorithm on how to solve such thing. If you look at example Monday: 9:00-13:00; 14:00-18:00 you will see that I want to show only working hours. I think that it is something like TimeRange, but I don't know how to code this.
UPDATE 2
To be more clear I will provide an example. User can enter working hours of procedure like a period, e.g. 9:00-12:00 Also user can enter non working hours of procedure like a period, e.g 10:00-11:00. For one day of week it is possible to enter as many time periods (working or non working) as user wants. Adding and storing this to database is not a problem.
Problem is to show time periods for user during preview.
So for example user entered:
- 9:00-12:00 working hours
- 10:00-11:00 non working hours
- 14:00-17:00 working hours
- 15:00-15:30 non working hours
I need to show all these like:
9:00-10:00; 11:00-12:00; 14:00-15:00; 15:30-17:00;
UPDATE 3
I think this may be related to graphs. Please help on selecting algorithm.