Skip to content

Commit

Permalink
Use local timezone date in careportal. Fixes #8304
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlounds committed Oct 25, 2024
1 parent 5b440b7 commit ed47426
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/client/careportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
14 changes: 14 additions & 0 deletions tests/careportal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require('should');
var benv = require('benv');
const moment = require("moment/moment");

var nowData = {
sgvs: [
Expand Down Expand Up @@ -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('2025-10-25');
});

});

0 comments on commit ed47426

Please sign in to comment.