F
Frank Rizzo
I need to get a Monday of the current week based on any date. I got the
function below working fine, but it feels hacky. And I can't find
anything in the framework. Is there a more elegant solution?
private DateTime GetMondayOfWeek(DateTime dt)
{
CultureInfo myCI = new CultureInfo("en-US");
while (myCI.Calendar.GetDayOfWeek(dt) != DayOfWeek.Monday)
dt = dt.AddDays(-1);
return dt;
}
function below working fine, but it feels hacky. And I can't find
anything in the framework. Is there a more elegant solution?
private DateTime GetMondayOfWeek(DateTime dt)
{
CultureInfo myCI = new CultureInfo("en-US");
while (myCI.Calendar.GetDayOfWeek(dt) != DayOfWeek.Monday)
dt = dt.AddDays(-1);
return dt;
}