18 lines
420 B
C#
18 lines
420 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EgwCoreLib.Utils
|
|
{
|
|
public static class DateTimeExtensions
|
|
{
|
|
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
|
|
{
|
|
int diff = (7 + (dt.DayOfWeek - startOfWeek)) % 7;
|
|
return dt.AddDays(-1 * diff).Date;
|
|
}
|
|
}
|
|
}
|