128 lines
3.6 KiB
C#
128 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EgwCoreLib.Utils
|
|
{
|
|
/// <summary>
|
|
/// Utility gestione calendario
|
|
/// </summary>
|
|
public class GestCalendario
|
|
{
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Calcolo data domenica di pasqua dell'YearReq indicato
|
|
/// </summary>
|
|
/// <param name="year"></param>
|
|
/// <returns></returns>
|
|
public static DateTime GetEasterSunday(int year)
|
|
{
|
|
int num = 0;
|
|
int num2 = 0;
|
|
int num3 = year % 19;
|
|
int num4 = year / 100;
|
|
int num5 = (num4 - num4 / 4 - (8 * num4 + 13) / 25 + 19 * num3 + 15) % 30;
|
|
int num6 = num5 - num5 / 28 * (1 - num5 / 28 * (29 / (num5 + 1)) * ((21 - num3) / 11));
|
|
num = num6 - (year + year / 4 + num6 + 2 - num4 + num4 / 4) % 7 + 28;
|
|
num2 = 3;
|
|
if (num > 31)
|
|
{
|
|
num2++;
|
|
num -= 31;
|
|
}
|
|
|
|
return new DateTime(year, num2, num);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco festività (limitato ad ITALIA)
|
|
/// </summary>
|
|
/// <param name="YearReq"></param>
|
|
/// <param name="CurrCult"></param>
|
|
/// <returns></returns>
|
|
public static List<EventDetail> ListHolidaysIta(int YearReq)
|
|
{
|
|
List<EventDetail> list = new List<EventDetail>();
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Capodanno",
|
|
When = new DateTime(YearReq, 1, 1)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Epifania",
|
|
When = new DateTime(YearReq, 1, 6)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Lavoro",
|
|
When = new DateTime(YearReq, 5, 1)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Ferragosto",
|
|
When = new DateTime(YearReq, 8, 15)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Ognissanti",
|
|
When = new DateTime(YearReq, 11, 1)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Immacolata",
|
|
When = new DateTime(YearReq, 12, 8)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Natale",
|
|
When = new DateTime(YearReq, 12, 25)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "S.Stefano",
|
|
When = new DateTime(YearReq, 12, 26)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Pasqua",
|
|
When = GetEasterSunday(YearReq)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Pasquetta",
|
|
When = GetEasterSunday(YearReq).AddDays(1.0)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Liberazione",
|
|
When = new DateTime(YearReq, 4, 25)
|
|
});
|
|
list.Add(new EventDetail
|
|
{
|
|
What = "Repubblica",
|
|
When = new DateTime(YearReq, 6, 2)
|
|
});
|
|
return list;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Public Classes
|
|
|
|
public class EventDetail
|
|
{
|
|
#region Public Properties
|
|
|
|
public string What { get; set; } = "";
|
|
public DateTime When { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Public Classes
|
|
}
|
|
} |