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;
- namespace P01CountWorkingDays
- {
- class Program
- {
- private static string input1;
- private static string input2;
- private static string format;
- private static DateTime startDate;
- private static DateTime endDate;
- private static DateTime[] holidays = new DateTime[]
- {
- new DateTime(1, 12, 24), // godina, mesec, den
- new DateTime(1, 12, 25),
- new DateTime(1, 12, 26),
- new DateTime(1, 01, 01),
- new DateTime(1, 03, 03),
- new DateTime(1, 05, 01),
- new DateTime(1, 05, 06),
- new DateTime(1, 05, 24),
- new DateTime(1, 09, 06),
- new DateTime(1, 09, 22),
- new DateTime(1, 11, 01),
- };
- static void Main(string[] args)
- {
- input1 = Console.ReadLine().Trim();
- input2 = Console.ReadLine().Trim();
- format = "dd-MM-yyyy";
- startDate = DateTime.ParseExact(input1, format, CultureInfo.InvariantCulture);
- endDate = DateTime.ParseExact(input2, format, CultureInfo.InvariantCulture);
- //RunWithErrors();
- int workindDays = 0;
- for (DateTime day = startDate; day <= endDate; day = day.AddDays(1))
- {
- DayOfWeek dayOfWeek = day.DayOfWeek;
- DateTime tempDate = new DateTime(1, day.Month, day.Day);
- if (!holidays.Contains(tempDate) && !dayOfWeek.Equals(DayOfWeek.Sunday) && !dayOfWeek.Equals(DayOfWeek.Saturday))
- {
- workindDays += 1;
- }
- }
- Console.WriteLine(workindDays);
- //main ends here
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement