This code has been working for a long time, but now it has broken when I try to pass DateTime.Now as an outageEndDate parameter:
public Outage(DateTime outageStartDate, DateTime outageEndDate, Dictionary<string, string> weeklyHours, string province, string localProvince) { this.outageStartDate = outageStartDate; this.outageEndDate = outageEndDate; this.weeklyHours = weeklyHours; this.province = province; localTime = TimeZoneInfo.FindSystemTimeZoneById(timeZones[localProvince]); if (outageStartDate < outageEndDate) { TimeZoneInfo remoteTime = TimeZoneInfo.FindSystemTimeZoneById(timeZones[province]); outageStartDate = TimeZoneInfo.ConvertTime(outageStartDate, localTime, remoteTime); outageEndDate = TimeZoneInfo.ConvertTime(outageEndDate, localTime, remoteTime);
The error message that I get on the last line is that the Kind property is not set correctly in the DateTime (outageEndDate) parameter. I googled Google and checked SO for examples, but I really don't understand the error message.
Any advice is appreciated.
Sincerely.
EDIT - exact error message:
The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. Parameter name: sourceTimeZone
EDIT: outageEndDate.Kind = Utc
Kevin source share