I have a small calendar tool in C #, and I'm trying to figure out how to convert from one array of DateTime objects to another. Here are the details:
I start with a collection of a DateTime object
IEnumerable<DateTime> slots = GetSlots();
where each DateTime represents the start time of an available slot (I think the open slot in the calendar) All slots within 30 minutes This is the task. For example:
var slots = new List<DateTime>()
slots.Add(DateTime.Today + new TimeSpan(5,00, 0));
slots.Add(DateTime.Today + new TimeSpan(9,00, 0));
slots.Add(DateTime.Today + new TimeSpan(9,30, 0));
slots.Add(DateTime.Today + new TimeSpan(10,00, 0));
slots.Add(DateTime.Today + new TimeSpan(10,30, 0));
slots.Add(DateTime.Today + new TimeSpan(11,00, 0));
slots.Add(DateTime.Today + new TimeSpan(16,30, 0));
in the above example, this means I'm free:
- 5:00 to 5:30
- From 9:00 to 9:30
- From 9:30 a.m. to 10:00 a.m.
- 10:00 to 10:30
- From 10:30 a.m. to 11:00 a.m.
- From 11:00 to 11:30
- From 4:30 to 5:00
because I take the time from the item in the collection as the start time and just add 30 minutes to it, and this is considered a free slot.
( 2 ) , 2- , "" . , 2 (120 ),
IEnumerable<DateTime> aggregateArray = MergeIntoLargerSlots(slots, 120);
"" , , . - 2 , . , aggregateArray 2 , :
- 9AM ( 9-11 (120 ).
- 9:30 ( 9: 30-11: 30 AM (120 ).
. 30 "" - , 9:05 - 11:05
, , 2-
, MergeIntoLargerSlots , , .