I've got a client/server application, written in WCF / C#3.5.
The server is in my local TimeZone, and clients are spreaded accross the world.
My current strategy is to use UTC DateTime everywhere on the server and in the database, and to let the clients handle correctly the UTC DateTimes they receive.
This means that everytime the client receives a message, its first task is to convert the DateTimes contained in the message from UTC to Local.
I've defined an interface, implemented by all my [DataContract] objects to help this task :
public interface IConvertToLocalTime {
void ConvertToLocalTime();
}
So I typically handle a message from the server this way :
public void ServerCallbackFoo(MyObject a, MyObject2 b)
{
a.ConvertToLocalTime();
b.ConvertToLocalTime();
// my business code goes there
}
This works fine, but I'm not very pleased with the fact that I've got to manually call the conversion method.
It seems to me that this task should be managed by the WCF framework. Am I missing something there? Is there a better way to automate the conversion ?