Invariantly convert ET DST/STD to UTC
I have logs that had been written in ET DST timezome, parsed the开发者_JS百科m and wrote to another log as UTC time (date.ToUniversalTime().GetDateTimeFormats('G', CultureInfo.InvariantCulture)[0]
). Now (when standart time is enabled) I try to run unit tests that compare logs and I face in an issue that now times differ in a hour.
Is there any way to invariantly compare outputs without recreating logs.
Instead of using the pattern 'G' (General Date Time Pattern) that does not include any time zone information you should look at using the 'O' (Round-Trip Date Time Pattern) as that will preserve time zone information and structure the string in such a way that it is easy to sort on.
O: 6/15/2009 1:45:30 PM -> 2009-06-15T13:45:30.0900000
G: 6/15/2009 1:45:30 PM -> 6/15/2009 1:45:30 PM (en-US)
精彩评论