using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SteamWare
{
///
/// Singolo dettaglio evento
///
public class EventDetail
{
///
/// Data di riferimento
///
public DateTime when { get; set; }
///
/// Nome evento
///
public string what { get; set; } = "";
}
///
/// Classe gestione procedure Calendario (es festività)
///
public class calendarMan
{
///
/// Calculate Easter Sunday for any given year.
/// src.: https://stackoverflow.com/a/2510411/1233379
///
/// The year to calcolate Easter against.
/// a DateTime object containing the Easter month and day for the given year
public static DateTime GetEasterSunday(int year)
{
int day = 0;
int month = 0;
int g = year % 19;
int c = year / 100;
int h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g + 15) % 30;
int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h + 1)) * (int)((21 - g) / 11));
day = i - ((year + (int)(year / 4) + i + 2 - c + (int)(c / 4)) % 7) + 28;
month = 3;
if (day > 31)
{
month++;
day -= 31;
}
return new DateTime(year, month, day);
}
///
/// Elenco festività per l'anno indicato
///
///
///
public static List elencoFestAnno(int anno)
{
List answ = new List();
// aggiungo le feste comandate...
answ.Add(new EventDetail() { what = "Capodanno", when = new DateTime(anno, 1, 1) });
answ.Add(new EventDetail() { what = "Epifania", when = new DateTime(anno, 1, 6) });
answ.Add(new EventDetail() { what = "Lavoro", when = new DateTime(anno, 5, 1) });
answ.Add(new EventDetail() { what = "Ferragosto", when = new DateTime(anno, 8, 15) });
answ.Add(new EventDetail() { what = "Ognissanti", when = new DateTime(anno, 11, 1) });
answ.Add(new EventDetail() { what = "Immacolata", when = new DateTime(anno, 12, 8) });
answ.Add(new EventDetail() { what = "Natale", when = new DateTime(anno, 12, 25) });
answ.Add(new EventDetail() { what = "S.Stefano", when = new DateTime(anno, 12, 26) });
// Pasqua + Pasquetta
answ.Add(new EventDetail() { what = "Pasqua", when = GetEasterSunday(anno) });
answ.Add(new EventDetail() { what = "Pasquetta", when = GetEasterSunday(anno).AddDays(1) });
// feste ITA
answ.Add(new EventDetail() { what = "Liberazione", when = new DateTime(anno, 4, 25) });
answ.Add(new EventDetail() { what = "Repubblica", when = new DateTime(anno, 6, 2) });
return answ;
}
}
}