/// <summary> /// Setting the grid to display the previous week /// </summary> protected void GetLastWeek() { DateTime sevenDaysFromNextWeek = BeginOfWeekDateTime.AddDays(-7); BeginOfWeekDateTime = sevenDaysFromNextWeek.Date; EndOfWeekDateTime = sevenDaysFromNextWeek.AddDays(6).Date; BeginOfWeek = BeginOfWeekDateTime.ToString("M"); EndOfWeek = EndOfWeekDateTime.ToString("M"); Day1Week = BeginOfWeekDateTime; Day2Week = BeginOfWeekDateTime.AddDays(1); Day3Week = BeginOfWeekDateTime.AddDays(2); Day4Week = BeginOfWeekDateTime.AddDays(3); Day5Week = BeginOfWeekDateTime.AddDays(4); Day6Week = BeginOfWeekDateTime.AddDays(5); Day7Week = BeginOfWeekDateTime.AddDays(6); PopulateShifts(); }
/// <summary> /// Setting the grid to display current week /// </summary> protected void SetGrid() { //converting times based on US Mountain standard time, as it does not get the correct time when deployed to azure var currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"); Today = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, currentTimeZone); BeginOfWeekDateTime = Today.AddDays(-(int)Today.DayOfWeek).Date; EndOfWeekDateTime = Today.AddDays(6 - (int)Today.DayOfWeek).Date; BeginOfWeek = BeginOfWeekDateTime.ToString("M"); EndOfWeek = EndOfWeekDateTime.ToString("M"); Day1Week = BeginOfWeekDateTime.Date; Day2Week = BeginOfWeekDateTime.AddDays(1); Day3Week = BeginOfWeekDateTime.AddDays(2); Day4Week = BeginOfWeekDateTime.AddDays(3); Day5Week = BeginOfWeekDateTime.AddDays(4); Day6Week = BeginOfWeekDateTime.AddDays(5); Day7Week = BeginOfWeekDateTime.AddDays(6); }