views:

22

answers:

1

This is more of a question about best pattern and practice than asking about any one particular method. We have app that is heavily reliant on dates and times and is hosted in the US. Sometimes it needs to perform actions based on those values, like emailing out reminders and expiring "single-use" session tokens.

However there are clients around the globe that need to access this app and have the dates and times display relative to their local time.

Clearly the solution should be to store the dates on the server side in a single time zone (UTC?) and then convert them back and forth from the local time settings of the user.

We are using silverlight 4 on the client and the ria services 1.0 stack over linq2sql on the server side. I am hoping someone knows if there is a way to automate this localization of date and time as much as possible and if so, what is the pattern to use for this.

Ideally we don't want to have to do a DateTime.ToLocalTime() every time we need to use a date. This has to be a common situation.

Is there a way to automatically shift dates and times into the client's local time zone on SL4?

+2  A: 

One thing that occurs to me as a way to solve the problem is to use a ValueConverter, but you're right, there's probably a better way (since this would require adding that logic to every place it displays in your application.

I'd be kinda nice if there were some option on the client-side proxy RIA services generates that'd let you turn something like that on.

Jonathan
The *format* of the date only becomes an issue once it is shown in the UI, so a converter is the correct approach - especially as you get the culture object nicely handed to you as one of the parameters :)
slugster
My problem with the converter is that I have to remember to put it on *every* binding in the UI. I'd be fine with it if there were a way to put there automatically (or even if you had a tool to tell you if it was missing anywhere). Sure, testing should tell you about it, but I'd still prefer to specify it in a single place.
Jonathan
thanks Jonathan, I guess a ValueConverter seems to be the only way to do this for now
Dale Halliwell