Skip to content

Instantly share code, notes, and snippets.

@garbuchev
Last active August 29, 2015 13:57
Show Gist options
  • Save garbuchev/9689024 to your computer and use it in GitHub Desktop.
Save garbuchev/9689024 to your computer and use it in GitHub Desktop.
using System;
class BeerTime
{
static void Main()
{
DateTime timeBeer = new DateTime();
Console.Write("Enter time: ");
bool isValid = DateTime.TryParse(Console.ReadLine(), out timeBeer);
if (isValid)
{
Console.Write(timeBeer.ToShortTimeString());
TimeSpan daytime = timeBeer.TimeOfDay;
TimeSpan endBeertime = new TimeSpan(3, 00, 00);
TimeSpan startBeertime = new TimeSpan(13, 00, 00);
if ((daytime < endBeertime) || (daytime > startBeertime))
{
Console.WriteLine(" is BEER TIME :)");
}
else
{
Console.WriteLine(" is non-beer time :(");
}
}
else
{
Console.WriteLine("Invalid time");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment