I want a DateTimeOffset value for tomorrow's date, 7 AM , Central Standard Time.
My current code is:
var tomorrow = DateTime.Now.AddDays(1);
var tomorrowDate = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, 07, 00, 00, DateTimeKind.Local);
DateTimeOffset datetimeOffsetInCentralTimeZone = new DateTimeOffset(tomorrowDate, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time").GetUtcOffset(tomorrowDate));
return datetimeOffsetInCentralTimeZone;
Is this correct? Is there an easier way to get the datetimeoffset value?
For this answer I'm making the following assumptions:
DateTimeOffsetin Central Time is required. (This seems to be implied in the question.)DateTimeOffsetwill be used for and it's possible the OP wants 7:00 AM CST and 6:00 AM CDT but that would be the less common case.)If you wanted to adjust the 7:00 AM time during Daylight Saving, the following code can be added to test for Daylight Saving, find the difference between Standard and Daylight (don't assume the difference is 1 hour), and modify the time.