From bb6110931a95a4741c1e93da3341a26bf7715a3f Mon Sep 17 00:00:00 2001 From: Laura Gomez Date: Tue, 2 Jul 2019 16:28:29 -0400 Subject: [PATCH] feat : added a StartofDay and EndofDay DateTime methods. --- .../Extensions/DateTimeExtensions.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs index bb32197..b76410a 100644 --- a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs +++ b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs @@ -63,5 +63,25 @@ namespace ICD.Common.Utils.Extensions bool success = times.OrderByDescending(dt => dt).TryFirst(dt => inclusive ? target >= dt : target > dt, out latestTime); return success ? latestTime : (DateTime?) null; } + + /// + /// Returns the DateTime representing the very start of the current day. + /// + /// + /// + public static DateTime StartOfDay(this DateTime extends) + { + return new DateTime(extends.Year, extends.Month, extends.Day, 0, 0, 0); + } + + /// + /// Returns the DateTime representing the very end of the current day. + /// + /// + /// + public static DateTime EndOfDay(this DateTime extends) + { + return extends.StartOfDay() + new TimeSpan(24, 0, 0); + } } }