Advertisement
zontak

beerTime

Mar 27th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. string startStr = "1:30 PM";
  2. string endStr = "3:00 AM";
  3.  
  4. DateTime start = DateTime.Parse(startStr);
  5. DateTime end = DateTime.Parse(endStr).AddDays(1);
  6.  
  7. string input = Console.ReadLine();
  8. DateTime time = DateTime.Parse(input);
  9. if (time.Hour < 12)
  10. {
  11. time = time.AddDays(1);
  12. }
  13.  
  14. bool isinRange = time >= start && time <= end;
  15.  
  16. if (isinRange)
  17. {
  18. Console.WriteLine("Beer Time");
  19. }
  20. else
  21. {
  22. Console.WriteLine("no beer");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement