Coffeehouse Post

Single Post Permalink

View Thread: MVVM and local time versus UTC
  • User profile image

    I'm no expert on MVVM, but to my thinking it should be done in the viewmodel.  The view should only be handling presentation, so that I can swap out the view without changing the behavior of the content.  The view should provide a means of setting a viewmodel property for what zone (format) I want the time in, and the viewmodel should then return the time property in that form.  However, that does not mean that any other code should use the presentation property.  Internal code should be operating on the UTC form, for the obvious reasons, letting the viewmodel maintain the translated version for the view. That particular case doesn't seem like it should be very difficult to implement (certainly some things are difficult to implement cleanly for a variety of reasons).

    Of course, that is speaking generally.  Specifics of whatever technology you are using may influence your decision.