locked
When times and UTC RRS feed

  • Question

  •  

    For adding data to HealthVault, do I need to set the When to a universal time?

     

    Right now I do this

     

    Weight NewThing = new Weight();

    NewThing.When = new HealthServiceDateTime(DateTime.Now.ToUniversalTime());

     

     

    should I do this instead?

     

    Weight NewThing = new Weight();

    NewThing.When = new HealthServiceDateTime(DateTime.Now);

     

     

    And when I add data to my system, I do this

    NewLocalItem.EventDate = Convert.ToDateTime(WeightThing.EffectiveDate.ToLocalTime().ToString("MM/dd/yyyy hh:mm tt"));

     

     

    I see sample code where ToUniversalTime is not used, but what about data that comes from different timezones? I see the HealthServiceDateTime has a timezone, but a HealthServiceDate does not.

     

    Our sync works, but I need to know if I should remove the whole universal time business.

     

    Thank you!

    Tuesday, June 3, 2008 6:35 PM

Answers

  • For sync purposes you should use the audit information.  See the LastUpdated property in HealthRecordItem.  This is always a UTC date/time.

     

    The time zone is not automatically set.

     

    Jeff Jones

     

    Wednesday, June 4, 2008 4:43 PM

All replies

  • In general, any user data in HealthVault is time-zoneless and any audit data is UTC. 

     

    We struggled with this for a while and had some really good feedback that led us to this design.  For example, lets say I am travelling to New York on business and I go for a run at 7am local time.  I upload the data from my watch to HealthVault and then go back to Redmond, WA.  I open my favorite HealthVault application to look at my aerobic sessions I would expect to see a 7am run, not a 4am run.  I'm way too lazy to get up at 4am to run.  We found this sort of pattern come up quite a lot.

     

    We offer the time zone information in HealthServiceDateTime so that if the timezone information is critical you can include it but it is then up to the application interpretting the data to decide whether or not its useful to them.  When creating or updating data with time zone data the date/time should be local time. Note, this is local time to the user not necessarily the application.

     

    Jeff Jones

     

     

     

    Wednesday, June 4, 2008 4:23 PM
  • Jeff,

    I appreciate the response. This will making syncing interesting. Our servers are on Pacific time, so if we have a user that uploads data from a different time zone on a value that collects time, the one with the later TIME will win. Is the TimeZone always set for a HealthServiceDateTime or is that up to the developer?

     

    Justin

     

    Wednesday, June 4, 2008 4:34 PM
  • For sync purposes you should use the audit information.  See the LastUpdated property in HealthRecordItem.  This is always a UTC date/time.

     

    The time zone is not automatically set.

     

    Jeff Jones

     

    Wednesday, June 4, 2008 4:43 PM