Creating an AFTimeRange should not be converting to UTC. Check the computer you are running the code on to make sure you are doing the conversion correct and what time zone it is set to. Here is something you can try:
AFTime y2k = new AFTime("1/1/2000 12:00:00 AM", CultureInfo.InvariantCulture);
Here is code byte that I use all the time without any issues:
public void GetPlotValues(DateTime start, DateTime end)
timeRange = new AFTimeRange(start, end);
1 of 1 people found this helpful
The problem is that Convert.ToDateTime method returns a DataTime object with its 'Kind' property set to 'Unspecified'. When creating an AFTime from a DateTime and the 'Kind' property is 'Unspecified' then the time is treated as UTC. So you can either create your DateTime objects so that the 'Kind' property is set to 'Local' (e.g. using the DateTime.SpecifyKind method) or you can pass the strings directly into the AFTimeRange constructor instead of a DateTime object. The strings will be interpreted as local time unless they have a time zone indicator in the string.
Thank you, that’s what I figured. What I ended up doing was to convert to universal time and that seems to be working!
AFTimeRange time = new AFTimeRange(startDate.ToUniversalTime(), endDate.ToUniversalTime());