I need the help of a guru in real time!
My goal is to write a tool (in .Net) that will display date and time values ββfrom a SharePoint database with a selected time zone offset. I found that SharePoint saves datetime values ββas UTC in its database. It shows them with a timezone offset that is stored as int (0 .. ~ 50). A little research showed that int is CDO code. It is not possible to convert the CDO code, with the exception of the manual matching I wrote, based on different sources.
Now I have a unit test failure with the following values: CDO - 34, time in UTC - 2011-05-26 14:55:00. From a GUI perspective, the time zone looks like "(GMT-05: 00) Indiana (East)." On my map 34, the time zone identifier is US Eastern Standard Time.
var id = "US Eastern Standard Time";
var zone = TimeZoneInfo.FindSystemTimeZoneById(id);
Console.WriteLine(zone);
Console.WriteLine(zone.StandardName);
Result:
(GMT-05:00) Indiana (East)
US Eastern Standard Time
Looks good, both are Indiana (East). Now I use the zone to convert the value:
var dateTime = new DateTime(2011, 05, 26, 14, 55, 00);
var converted = TimeZoneInfo.ConvertTimeFromUtc(dateTime, zone);
Console.WriteLine(converted);
And the result is 05/26/2011 10:55:00. But SharePoint shows it as 05/26/2011 09:55:00! This is why my unit test failed. I opened the timezoneconverter.com online tool. It is not possible to set the time zone as a CDO or .Net time zone identifier, so I selected "America / Indiana / Indianapolis":
14:55:00 Thursday May 26, 2011 in UTC converts to
10:55:00 Thursday May 26, 2011 in America/Indiana/Indianapolis
My converter has the same result. Then I chose America / Indiana / Knox:
14:55:00 Thursday May 26, 2011 in UTC converts to
09:55:00 Thursday May 26, 2011 in America/Indiana/Knox
Google Maps , , .
, SharePoint . ? CDO, Knox? ? ? , .
,