ExtensionMethod.NET Home of 820 C#, Visual Basic, F# and Javascript extension methods

FirstMondayOfYear

FirstMondayOfYear

Source

public static DateTime FirstMondayOfYear(int ThisYear)
{
    DateTime firstDay = new DateTime(ThisYear, 1, 1);
    return new DateTime(ThisYear, 1, (8 - (int)firstDay.DayOfWeek) % 7 + 1);
}

Example

DateTime mnd = DateExtensions.FirstMondayOfYear(2017);

Author: Hakan YILMAZ

Submitted on: 4 apr 2017

Language: C#

Type: FirstMondayOfYear

Views: 1514