This commit is contained in:
Your Name 2025-05-06 10:44:43 +03:00
parent f5bf9477db
commit 460e456165

View File

@ -9,7 +9,6 @@ public class Calculations
TimeSpan endWorkingTime,
int consultationTime)
{
// Список занятых интервалов
var busy = new List<(DateTime Start, DateTime End)>();
for (int i = 0; i < startTimes.Length; i++)
{
@ -18,11 +17,9 @@ public class Calculations
busy.Add((start, end));
}
// Рабочее время
var workStart = DateTime.Today.Add(beginWorkingTime);
var workEnd = DateTime.Today.Add(endWorkingTime);
// Разбиваем на слоты
var result = new List<string>();
var current = workStart;
@ -31,7 +28,7 @@ public class Calculations
var slotEnd = current.AddMinutes(consultationTime);
bool isOverlapping = busy.Any(b =>
current < b.End && slotEnd > b.Start // перекрытие
current < b.End && slotEnd > b.Start
);
if (!isOverlapping)
@ -39,7 +36,7 @@ public class Calculations
result.Add($"{current:HH:mm}-{slotEnd:HH:mm}");
}
current = slotEnd; // шаг по времени строго по длительности
current = slotEnd;
}
return result.ToArray();