Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace P01_CountWorkingDays
- {
- class Date
- {
- public int day { get; set; }
- public int month { get; set; }
- public int year { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- var startDate = Console.ReadLine();
- var endDate = Console.ReadLine();
- DateTime firstDate = DateTime.ParseExact(startDate, "d-M-yyyy",
- CultureInfo.InvariantCulture);
- DateTime secondDate = DateTime.ParseExact(endDate, "d-M-yyyy",
- CultureInfo.InvariantCulture);
- var workDaysCounter = 0;
- for (DateTime date = firstDate; date <= secondDate; date = date.AddDays(1))
- {
- if (!((date.Month == 01 && date.Day == 01) || (date.Month == 03 && date.Day == 03) || (date.Month == 05 && date.Day == 01) ||
- (date.Month == 05 && date.Day == 06) || (date.Month == 05 && date.Day == 24) || (date.Month == 09 && date.Day == 06) ||
- (date.Month == 09 && date.Day == 22) || (date.Month == 10 && date.Day == 01) || (date.Month == 12 && date.Day == 24) ||
- (date.Month == 12 && date.Day == 25) || (date.Month == 12 && date.Day == 26)))
- {
- if (!((date.DayOfWeek.Equals(DayOfWeek.Saturday) || (date.DayOfWeek.Equals(DayOfWeek.Sunday)))))
- {
- workDaysCounter++;
- }
- }
- }
- Console.WriteLine(workDaysCounter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement