You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Patient List shows many dates, such as those associated with clinic visits, lab result times, or whatever admins have configured Leaf to query and show.
However, the values shown to the user currently do not match those in the clinical database or Leaf API (unless you live in the UK, and unrelated to de-identification & date-shifting).
Why is this? The reason is that JavaScript internally tracks dates as UTC ticks, and assumes any input timestamp strings are in Greenwich Mean time, and "helpfully" adds the user's timezone hour difference to the resulting value. If the values stored in the clinical database are not UTC, then this hour-shifting is erroneous.
For example:
newDate("2021-05-28T14:00:00Z")// Date Fri May 28 2021 07:00:00 GMT-0700 (Pacific Daylight Time)
To get around this (and avoid pulling in 3rd party libraries such as Moment in web workers), a function such as:
// Adapted from https://stackoverflow.com/a/36768608constparseTimestamp=(timestampStr)=>{const_date=newDate(timestampStr);returnnewDate(_date.getTime()+(_date.getTimezoneOffset()*60*1000));};
Should be sufficient for a fix. Let's switch to using this.
parseTimestamp("2021-05-28T14:00:00Z")// Date Fri May 28 2021 14:00:00 GMT-0700 (Pacific Daylight Time)
The text was updated successfully, but these errors were encountered:
The
Patient List
shows many dates, such as those associated with clinic visits, lab result times, or whatever admins have configured Leaf to query and show.However, the values shown to the user currently do not match those in the clinical database or Leaf API (unless you live in the UK, and unrelated to de-identification & date-shifting).
Why is this? The reason is that JavaScript internally tracks dates as UTC ticks, and assumes any input timestamp strings are in Greenwich Mean time, and "helpfully" adds the user's timezone hour difference to the resulting value. If the values stored in the clinical database are not UTC, then this hour-shifting is erroneous.
For example:
Note that 2pm has become 7am.
The current JSON string (via the Leaf API) to
Date
conversion happens in the Patient List webworker.To get around this (and avoid pulling in 3rd party libraries such as Moment in web workers), a function such as:
Should be sufficient for a fix. Let's switch to using this.
The text was updated successfully, but these errors were encountered: