Это быстрее, чем функции LINQ и Lambda. Также многие переменные можно удалить, просто добавив их для наглядности. Уже проверено, работает.
static void Main(string[] args)
{
StreamReader reader = new StreamReader("a.txt");
string[] time = Console.ReadLine().Split(':');
int hour = 0;
int minute = 0;
try
{
hour = Convert.ToInt32(time[0]);
minute = Convert.ToInt32(time[1]);
}
catch
{
Console.WriteLine("The input must be something like aa:bb, with aa > 00 and aa < 24, bb >= 00 and bb <=53");
return;
}
string[] first_time;
string[] second_time;
string[] time_frame;
int first_hour;
int first_minute;
int second_hour;
int second_minute;
DateTime _date = new DateTime(1, 1, 1, hour, minute, 0);
DateTime first_date, second_date;
string line = "";
string[] tokens;
while ((line = reader.ReadLine()) != null)
{
tokens = line.Split(' ');
time_frame = tokens[tokens.Length - 1].Split('-');
first_time = time_frame[0].Split(':');
first_hour = Convert.ToInt32(first_time[0]);
first_minute = Convert.ToInt32(first_time[1]);
first_date = new DateTime(1, 1, 1, first_hour, first_minute, 0);
second_time = time_frame[1].Split(':');
second_hour = Convert.ToInt32(second_time[0]);
second_minute = Convert.ToInt32(second_time[1]);
second_date = new DateTime(1, 1, 1, second_hour, second_minute, 0);
if (_date >= first_date && _date <= second_date)
{
for (int i = 0; i < tokens.Length - 1; i++)
{
Console.Write(tokens[i]);
Console.Write(" ");
}
Console.WriteLine("");
}
}
reader.Close();
}