diff --git a/X10D/DateTimeExtensions.cs b/X10D/DateTimeExtensions.cs index 1bbcbe1..fb4874b 100644 --- a/X10D/DateTimeExtensions.cs +++ b/X10D/DateTimeExtensions.cs @@ -66,10 +66,11 @@ /// The current day of week. public static DateTime Last(this DateTime current, DayOfWeek dayOfWeek) { - DateTime last = current.LastDayOfMonth(); + DateTime last = current.LastDayOfMonth(); + DayOfWeek lastDayOfWeek = last.DayOfWeek; - last = last.AddDays(Math.Abs(dayOfWeek - last.DayOfWeek) * -1); - return last; + int diff = -Math.Abs(dayOfWeek - lastDayOfWeek); + return last.AddDays(diff); } /// @@ -78,7 +79,7 @@ /// The current date. public static DateTime Midnight(this DateTime current) { - return new DateTime(current.Year, current.Month, current.Day); + return new DateTime(current.Year, current.Month, current.Day, 0, 0, 0); } ///