Skip to content

Instantly share code, notes, and snippets.

@Nikola-Andreev
Created July 5, 2016 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikola-Andreev/f133647b44e64f5a74094260185d98e8 to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/f133647b44e64f5a74094260185d98e8 to your computer and use it in GitHub Desktop.
Holidays between two dates.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Globalization;
namespace Praktice
{
class Program
{
static void Main(string[] args)
{
var startDate = DateTime.ParseExact(Console.ReadLine(),
"d.M.yyyy", CultureInfo.InvariantCulture);
var endDate = DateTime.ParseExact(Console.ReadLine(),
"d.M.yyyy", CultureInfo.InvariantCulture);
var holidaysCount = 0;
for (var date = startDate; date <= endDate; date=date.AddDays(1))
if (date.DayOfWeek == DayOfWeek.Saturday ||
date.DayOfWeek == DayOfWeek.Sunday) holidaysCount++;
Console.WriteLine(holidaysCount);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment