Feedback

C# - Ostersonntag und Ostermontag ermitteln

Veröffentlicht von am 10/4/2008
(1 Bewertungen)
Zwei Funktionen die den Ostersonntag und den Ostermontag ermitteln.
/// <summary>
/// Gets the easter sunday [Ostersonntag].
/// </summary>
/// <param name="Year">The year for calculation.</param>
/// <returns>DateTime object with the easter sunday.</returns>
public static DateTime GetEasterSunday(int Year)
{
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;
	int e = 0;
	int f = 0;

	a = Year % 19;
	b = Year / 100;
	c = (8 * b + 13) / 25 - 2;
	d = b - (Year / 400) - 2;
	e = (19 * (Year % 19) + ((15 - c + d) % 30)) % 30;

	if (e == 28)
	{
		if (a > 10)
			e = 27;
	}
	else if (e == 29)
	{
		e = 28;
	}
	f = (d + 6 * e + 2 * (Year % 4) + 4 * (Year % 7) + 6) % 7;
	DateTime dtRet = new DateTime(Year, 3, 1);
	dtRet = dtRet.AddDays(Convert.ToDouble(e + f + 21));
	return dtRet;
}
#endregion

#region [GetEasterMonday]
/// <summary>
/// Gets the easter monday [Ostermontag].
/// </summary>
/// <param name="Year">The year for calculation.</param>
/// <returns>DateTime object with the easter monday.</returns>
public static DateTime GetEasterMonday(int Year)
{
	DateTime dt = GetEasterSunday(Year);
	dt = dt.AddDays(Convert.ToDouble(1));
	return dt;
}
Abgelegt unter Datum, Date, Ostermontag.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!