/// <summary>
/// Validates if the start and end times are in the future.
/// </summary>
/// <param name="date">The date of the shift (in local time).</param>
/// <param name="start">The start time of the shift (in local time).</param>
/// <param name="end">The end time of the shift (in local time).</param>
/// <returns>True if the shift is in the future; otherwise, false.</returns>
public static bool IsScheduledInFuture(DateTime date, TimeOnly start, TimeOnly end)
{
// Combine the provided date with the start and end times to create local DateTime values
var localStart = date.Date.Add(start.ToTimeSpan());
var localEnd = end > start
? date.Date.Add(end.ToTimeSpan()) // Same day
: date.Date.AddDays(1).Add(end.ToTimeSpan()); // Next day for overnight shifts
// Convert local times to UTC explicitly
var utcStart = localStart.ToUniversalTime();
var utcEnd = localEnd.ToUniversalTime();
// Get current UTC time
var now = DateTime.UtcNow;
// Ensure the shift starts and ends in the future
return utcStart > now && utcEnd > now;
}
/// <summary>
/// Validates if the start and end times are in the future.
/// </summary>
/// <param name="date">The date of the shift (in local time).</param>
/// <param name="start">The start time of the shift (in local time).</param>
/// <param name="end">The end time of the shift (in local time).</param>
/// <returns>True if the shift is in the future; otherwise, false.</returns>
public static bool IsScheduledInFuture(DateTime date, TimeOnly start, TimeOnly end)
{
// Combine the provided date with the start and end times to create local DateTime values
var localStart = date.Date.Add(start.ToTimeSpan());
var localEnd = end > start
? date.Date.Add(end.ToTimeSpan()) // Same day
: date.Date.AddDays(1).Add(end.ToTimeSpan()); // Next day for overnight shifts
// Convert local times to UTC explicitly
var utcStart = localStart.ToUniversalTime();
var utcEnd = localEnd.ToUniversalTime();
// Get current UTC time
var now = DateTime.UtcNow;
// Ensure the shift starts and ends in the future
return utcStart > now && utcEnd > now;
}