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 SA 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 DateTime.SpecifyKind(TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, pacificZone),DateTimeKind.Local); } public static DateTime Today() { return TimeZoneInfo.ConvertTimeFromUtc(DateTime.Today, pacificZone); } } }