I can take a look at this today - looks like the TZ might not be getting applied correctly and fractional seconds parsing might be messing up the seconds field.
@mcalsyn
This is still not fixed. Or if it is can i get a clarification?
I know that winforms app knows current culture, and tinyclr does not, and its always UTC (is that correct?) so if you set time like below, whats the use of ToLocal, ToUniversal?
Time setTime = Json.DeserializeTime(rawData);
rtc.SetRtcTime(setTime.DateTime);
rtc.SetSystemTime();
Debug.WriteLine(setTime.DateTime.ToString());
Debug.WriteLine(setTime.DateTime.ToLocalTime().ToString());
Debug.WriteLine(setTime.DateTime.ToUniversalTime().ToString());
Debug.WriteLine(DateTime.Now.ToString());
Debug.WriteLine(DateTime.Now.ToLocalTime().ToString());
Debug.WriteLine(DateTime.Now.ToUniversalTime().ToString());
STRING
2021-04-19T16:47:24.1167125+02:00
COMMA
STRING
Instruction
COLON
NUMBER
3
RBRACE
END
04/19/2021 14:43:45 RTC Set Rtc: 04/19/2021 14:47:24
04/19/2021 14:47:24 RTC Set System Time: 04/19/2021 14:47:24
04/19/2021 14:47:24
04/19/2021 14:47:24
04/19/2021 14:47:24
04/19/2021 14:47:24
04/19/2021 14:47:24
04/19/2021 14:47:24
The JSON code is always representing the time as UTC. That is, it is adding the negation of the timezone offset to the time and setting the DateTime.Kind to DateTimeKind.UTC.
Because the DateTimeKind is UTC, ToUniversalTime shouldn’t do anything. ToLocalTime() will only return a local time if you have set a timezone offset with SystemTime.SetTime(DateTime time, int offset). The set functions that you called in your code do not establish a TZ offset.