Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Globalization;
- class BeerTime
- {
- static void Main ()
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- Console.Write(@"Please, enter your time in format ""hh:mm TT"",
- (example 05:30 PM), YOUR TIME = ");
- string timeStr = Console.ReadLine();
- DateTime customTime;
- if (DateTime.TryParse(timeStr, out customTime))
- Console.WriteLine("Converted '{0}' to {1} ({2}).", timeStr, customTime,
- customTime.Kind);
- else
- {
- Console.WriteLine("'{0}' is not in an acceptable format.", timeStr);
- Console.WriteLine("Error - Invalid Time !!!");
- Console.ReadLine();
- return;
- }
- DateTime startBeerTime = DateTime.Parse("01:00 PM");
- DateTime endBeerTime = DateTime.Parse("03:00 AM");
- if ((customTime >= endBeerTime) && (customTime < startBeerTime))
- {
- Console.WriteLine("Now is NON-BEER TIME !");
- }
- else
- {
- Console.WriteLine("Now is BEER TIME !");
- }
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement