diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 514dbf5d650..10f777c8ee1 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]); + eventDate.val(time.format('YYYY-MM-DD')); + eventTime.val(time.format('HH:mm')); } function mergeDateAndTime () { diff --git a/tests/careportal.test.js b/tests/careportal.test.js index 1da34673535..6284e7b011a 100644 --- a/tests/careportal.test.js +++ b/tests/careportal.test.js @@ -2,6 +2,7 @@ require('should'); var benv = require('benv'); +const moment = require("moment/moment"); var nowData = { sgvs: [ @@ -98,4 +99,17 @@ describe('careportal', function ( ) { }); + it('uses local timezone date, not UTC (8304) ', async () =>{ + const client = window.Nightscout.client; + client.init(); + // sleep(50); + + const fakeNow = moment.parseZone('2024-10-25T23:00:00-05:00'); + client.ctx.moment = () => (fakeNow); + + client.careportal.prepare(); + + $('#eventDateValue').val().should.equal('2024-10-25'); + }); + });