// Copyright Epic Games, Inc. All Rights Reserved. namespace HordeServer.Utilities { /// /// Extension methods for /// public static class TimeZoneInfoExtensions { /// /// Gets the start of the day for the given datetime in UTC, respecting the configured timezone. /// /// Time zone to adjust for /// Time to convert /// UTC datetime for the start of the day public static DateTime GetStartOfDayUtc(this TimeZoneInfo timeZone, DateTime time) { DateTime currentTimeLocal = TimeZoneInfo.ConvertTime(time, timeZone); DateTime startOfDayLocal = currentTimeLocal - currentTimeLocal.TimeOfDay; return TimeZoneInfo.ConvertTime(startOfDayLocal, timeZone, TimeZoneInfo.Utc); } } }