3 Replies Latest reply on May 31, 2013 2:04 PM by Rick Davin

    WebParts Local DateTime Problem

    Rick Davin

      I don’t mess around with PI WebParts very much, but colleagues have reported a data problem to me.  I have an AFAttribute that is a DateTime data type set to LocalTime, meaning it’s .Value is a .NET DateTime object with its Kind property explicitly set to Local.  The attribute’s value appears correctly in PB and PSE but displays incorrectly in WebParts.   It seems that WebParts grabs the .Value’s local DateTime without any regard to DateTimeKind, which is the same as considering it Unspecified, which is the same as treating it implicitly Utc.  WebParts then attempts to convert that date to local time, which it alreadys was but instead shifts it further away from the correct local time.

       

      E.g. I am in Central Time USA, currently with DST resulting in a -5:00 offset from UTC for today (5/29/2013).   The value from my AFAttribute is 5/29/2013 4:00 AM LocalTime to me (again it's Kind is explicitly Local).  It’s equivalent in UTC would be 5/29/2013 9:00 AM.  But WebParts is taking the 5/29/2013 4:00 AM and doesn’t convert it to UTC but simply treats it – at 4:00 AM – as the UTC time.  Later it then attempts to convert that “UTC” time to be local, so what the user actually sees is 5/28/2013 11:00 PM.  So the user sees the wrong time.

       

      The only other quasi-related issue I could find is Issue No.  23995OSI8, GMT time is displayed for AF Table Lookup attribute of type datetime instead of localized time.  I am using AF and a localized DateTime but it’s not from an AFTable.

       

      "http://techsupport.osisoft.com/Techsupport/NonTemplates/Known%20Issues/issues.aspx?issuetype=Known%20Issues&id=61130"