Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logged Treatment has incorrect date. Advances on GMT rather than local time zone. #8304

Open
ewingate opened this issue Oct 17, 2024 · 2 comments

Comments

@ewingate
Copy link

Describe the bug
When logging a treatment the date is changing based on GMT rather than on the local time zone. For us this means treatments logged after 6pm will have tomorrows date.

Steps to reproduce the behavior:

  • Date has rolled over in GMT *
  1. Go to '+'
  2. Click on 'Event Time'
  3. Enter a time
  4. Date will be for GMT, not local

Expected behavior
Date would be local

Screenshots
If applicable, add screenshots to help explain your problem.

Your setup information

  • Version 15.0.2

Additional context
Using Heroku to roll back to Version 14.2.6 fixes issue.

@adamlounds
Copy link

adamlounds commented Oct 24, 2024

AFAICT this is a front-end issue where the UI is displaying the wrong date when the "Log a treatment" drawer is opened.

To reproduce, I set system time zone to honolulu/HI, USA, which has a different time zone to me (london, UK).
Time at testing was around 2024-10-23 09:30 BST, 2024-10-23 08:30 UTC and 2024-10-22 22:30 AST.

The 'Log a Treatment' drawer (#treatmentDrawer) opens with the correct 'now' time, but the UTC date (ie 24th not 23rd as expected) in the eventDateValue field. Select "other" as the event time, and enter a time (eg 22:30). The confirmation dialog shows the UTC date, and the api request is made with an incorrect timestamp, as it uses the wrong date when converting to UTC.

Screenshot 2024-10-23 at 22 38 20 (note: system time in mac toolbar is 23 October 22:38. Date in "Event Time" and confirmation popup is **24 October**, not 23)

f/e converts date/time shown in confirmation dialog to UTC before making API request, and incorrectly uses 2024-10-25 instead of 2024-10-24 for created_at

[{
    "enteredBy": "adam",
    "eventType": "BG Check",
    "glucose": 5.5,
    "glucoseType": "Finger",
    "units": "mmol",
    "created_at": "2024-10-25T08:30:00.000Z",
    "utcOffset": 0
}]

Note: if you leave the event time as 'now' then the confirmation popup and subsequent api request are correct (although the "event time" in the is still wrong)

Screenshot 2024-10-23 at 22 25 14 (note 24 oct in drawer, but 23 oct in confirmation dialog)
[{
    "enteredBy": "adam",
    "eventType": "BG Check",
    "glucose": 5.5,
    "glucoseType": "Finger",
    "units": "mmol",
    "created_at": "2024-10-24T08:30:20.259Z",
    "utcOffset": 0,
    "_id": "671a059ed689f977f76c4874"
}]

(when using an event time of "now", the correct date is used to calculate the UTC created_at value)

Confirmed that this does not occur on nightscout 14.2.6.

Workaround: double-check and ensure that the event date is correct before submitting. Confirmed that doing this will log data with the correct timestamp.

@adamlounds
Copy link

Patch:

diff --git a/lib/client/careportal.js b/lib/client/careportal.js
index 514dbf5d..1f59101b 100644
--- a/lib/client/careportal.js
+++ b/lib/client/careportal.js
@@ -18,8 +18,8 @@ function init (client, $) {

   function setDateAndTime (time) {
     time = time || client.ctx.moment();
-    eventTime.val(time.hours() + ":" + time.minutes());
-    eventDate.val(time.toISOString().split('T')[0]);
+    eventTime.val(time.format('HH:mm'));
+    eventDate.val(time.format('YYYY-MM-DD'));
   }

   function mergeDateAndTime () {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants