Advertisement
Ivakis

Untitled

Jun 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace P01_CountWorkingDays
  9. {
  10. class Date
  11. {
  12. public int day { get; set; }
  13.  
  14. public int month { get; set; }
  15.  
  16. public int year { get; set; }
  17.  
  18. }
  19. class Program
  20. {
  21. static void Main(string[] args)
  22. {
  23. var startDate = Console.ReadLine();
  24. var endDate = Console.ReadLine();
  25.  
  26. DateTime firstDate = DateTime.ParseExact(startDate, "d-M-yyyy",
  27. CultureInfo.InvariantCulture);
  28.  
  29. DateTime secondDate = DateTime.ParseExact(endDate, "d-M-yyyy",
  30. CultureInfo.InvariantCulture);
  31.  
  32. var workDaysCounter = 0;
  33.  
  34. for (DateTime date = firstDate; date <= secondDate; date = date.AddDays(1))
  35. {
  36. if (!((date.Month == 01 && date.Day == 01) || (date.Month == 03 && date.Day == 03) || (date.Month == 05 && date.Day == 01) ||
  37. (date.Month == 05 && date.Day == 06) || (date.Month == 05 && date.Day == 24) || (date.Month == 09 && date.Day == 06) ||
  38. (date.Month == 09 && date.Day == 22) || (date.Month == 10 && date.Day == 01) || (date.Month == 12 && date.Day == 24) ||
  39. (date.Month == 12 && date.Day == 25) || (date.Month == 12 && date.Day == 26)))
  40. {
  41. if (!((date.DayOfWeek.Equals(DayOfWeek.Saturday) || (date.DayOfWeek.Equals(DayOfWeek.Sunday)))))
  42. {
  43. workDaysCounter++;
  44. }
  45.  
  46. }
  47.  
  48. }
  49. Console.WriteLine(workDaysCounter);
  50.  
  51. }
  52.  
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement