Rock.ExtensionMethods.StartOfWeek C# (CSharp) Méthode

StartOfWeek() public static méthode

Returns the date of the start of the week for the specified date/time For example, if Monday is considered the start of the week: "2015-05-13" would return "2015-05-11" from http://stackoverflow.com/a/38064/1755417
public static StartOfWeek ( this dt, DayOfWeek startOfWeek ) : System.DateTime
dt this The dt.
startOfWeek DayOfWeek The start of week.
Résultat System.DateTime
        public static DateTime StartOfWeek( this DateTime dt, DayOfWeek startOfWeek )
        {
            int diff = dt.DayOfWeek - startOfWeek;
            if ( diff < 0 )
            {
                diff += 7;
            }

            return dt.AddDays( -1 * diff ).Date;
        }