Im trying to perform a check is entered time inside specified time interval but Im stuck... I have one main block and another class which perform the check is the entered time inside the interval but I keep getting "No overload for method 'IsBetween' takes 0 arguments" when I try to call the method and get simple bool true or false, I know that solution is probably really simple but I just cant figure it out... :
static void Main()
{
var currentTime = Console.ReadLine();
DateTime now = Convert.ToDateTime(currentTime);
var dateNow = DateTime.Now;
var startTime = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 13, 0, 0);
var endTime = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 3, 0, 0);
}
This is my class for check :
public static class TimeExtensions
{
public static bool IsBetween(this DateTime now, DateTime startTime, DateTime endTime)
{
if (now.TimeOfDay == startTime.TimeOfDay) return true;
if (now.TimeOfDay == endTime.TimeOfDay) return true;
if (startTime.TimeOfDay <= endTime.TimeOfDay)
return (now.TimeOfDay >= startTime.TimeOfDay && now.TimeOfDay <= endTime.TimeOfDay);
else
return !(now.TimeOfDay >= endTime.TimeOfDay && now.TimeOfDay <= startTime.TimeOfDay);
}
}