I am creating the proxy like this:
OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null);
serviceProxy.EnableProxyTypes();
serviceProxy.CallerId = "xxx"
I then retrieve values from CRM and in this specific example I am setting ASP.Net Web Form textbox controls with the values from CRM.
Right now for each textbox control with a date I run it through this function:
private static string CRMDateToLocalTime (DateTime datetime)
{
DateTime UTCDate = Convert.ToDateTime(datetime);
return UTCDate.ToLocalTime().ToString();
}
To get the local time. This is fine, because I know that CRM is sending UTC dates. But another developer might come along later down the line and add some more date fields but not realise that the dates coming out of CRM are UTC and in need of conversion.
I thought it might be useful if we could so something like this:
OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null);
serviceProxy.EnableProxyTypes();
serviceProxy.CallerId = "xxx"
serviceProxy.UseCallerTimezone = true;
So that we could guarantee the output to the client.
I know, I know... we could just educate and tell people about this in code comments etc, but its more about guaranteeing a mistake like this wont happen. We are in the UK, so half of the year is the same as UTC and the other half is not. Thus its quite easy to make the mistake of pulling down the value from CRM and not release that when UK enters daylight saving time all the dates will be wrong.