using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Church.Net.Utility { public static class DateTimeHelper { private static TimeZoneInfo pacificZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); public static DateTime GetNextWeekday(DateTime start, DayOfWeek day) { // The (... + 7) % 7 ensures we end up with a value in the range [0, 6] int daysToAdd = ((int)day - (int)start.DayOfWeek + 7) % 7; return start.AddDays(daysToAdd); } public static DateTime Now() { return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, pacificZone); } public static DateTime Today() { return Now().Date; } } }