Created
June 3, 2016 11:37
-
-
Save Nikola-Andreev/e30f6dc56dbd62860d9b80494eb9e887 to your computer and use it in GitHub Desktop.
Count working days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Numerics; | |
using System.Globalization; | |
using System.Text.RegularExpressions; | |
namespace Praktice | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string startDate = Console.ReadLine(); | |
string endDate = Console.ReadLine(); | |
string format = "dd-MM-yyyy"; | |
CultureInfo provider = CultureInfo.InvariantCulture; | |
DateTime start = DateTime.ParseExact(startDate, format, provider); | |
DateTime end = DateTime.ParseExact(endDate, format, provider); | |
List<string> hollydays = new List<string>() {"01-01","03-03","01-05","06-05","24-05","06-10", "22-10", "01-11","24-12","25-12","26-12" }; | |
int count = 0; | |
for (DateTime i = start; i <= end; i = i.AddDays(1.0)) | |
{ | |
string test = i.ToString(); | |
string dateToCheck = test.Substring(0, 2)+"-"+test.Substring(3,2); | |
string a = i.DayOfWeek.ToString(); | |
if (!hollydays.Contains(dateToCheck)) | |
{ | |
if ( a !="Saturday" && a != "Sunday") | |
{ | |
count++; | |
} | |
} | |
} | |
Console.WriteLine(count); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment