diff --git a/lib/report/reportclient.js b/lib/report/reportclient.js
index cb294640fe9..bf806591436 100644
--- a/lib/report/reportclient.js
+++ b/lib/report/reportclient.js
@@ -258,9 +258,11 @@ var init = function init () {
function datefilter () {
if ($('#rp_enabledate').is(':checked')) {
matchesneeded++;
- var from = moment.tz($('#rp_from').val().replace(/\//g, '-') + 'T00:00:00', zone);
- var to = moment.tz($('#rp_to').val().replace(/\//g, '-') + 'T23:59:59', zone);
+ var from = moment.tz(moment($('#rp_from').val()).startOf('day'), zone).startOf('day');
+ var to = moment.tz(moment($('#rp_to').val()).endOf('day'), zone).endOf('day');
timerange = '&find[created_at][$gte]=' + from.toISOString() + '&find[created_at][$lt]=' + to.toISOString();
+
+ console.log("FROM", from.format( ), "TO", to.format( ), 'timerange', timerange);
//console.log($('#rp_from').val(),$('#rp_to').val(),zone,timerange);
while (from <= to) {
if (daystoshow[from.format('YYYY-MM-DD')]) {
diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js
index 49aad99ed16..c44cdf0386f 100644
--- a/lib/report_plugins/daytoday.js
+++ b/lib/report_plugins/daytoday.js
@@ -96,7 +96,9 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
var fatSum = 0;
daytoday.prepareHtml(sorteddaystoshow);
+ console.log('DAY2DAY', 'sorteddaystoshow', sorteddaystoshow);
sorteddaystoshow.forEach(function eachDay (day) {
+
drawChart(day, datastorage[day], options);
});
@@ -168,7 +170,7 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
// create svg and g to contain the chart contents
charts = d3.select('#daytodaychart-' + day).html(
'' +
- report_plugins.utils.localeDate(day) +
+ report_plugins.utils.localeDate(moment(day)) +
'
'
).append('svg');
@@ -432,8 +434,8 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
contextCircles.exit()
.remove();
- var to = moment(day).add(1, 'days');
- var from = moment(day);
+ var from = moment.tz(moment(day), profile.getTimezone( )).startOf('day');
+ var to = moment(from.clone( )).add(1, 'days');
var iobpolyline = ''
, cobpolyline = '';
diff --git a/tests/reports.test.js b/tests/reports.test.js
index 947eb5e5b03..bcaadbaf7cc 100644
--- a/tests/reports.test.js
+++ b/tests/reports.test.js
@@ -30,7 +30,7 @@ var someData = {
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z&count=1000': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T00:00:00.000Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}],
'/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}],
'/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}],
- '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.000Z': [
+ '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-08T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
{'created_at':'2015-08-10T00:00:00.000Z'},
@@ -63,7 +63,7 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
- '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.000Z': [
+ '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
{'created_at':'2015-08-10T00:00:00.000Z'},
@@ -96,7 +96,89 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
- '/api/v1/devicestatus.json&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.000Z?find[openaps][$exists]=true&count=1000': [
+ '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-08T23:59:59.999Z': [
+ {'created_at':'2015-08-08T00:00:00.000Z'},
+ {'created_at':'2015-08-09T00:00:00.000Z'},
+ {'created_at':'2015-08-10T00:00:00.000Z'},
+ {'created_at':'2015-08-11T00:00:00.000Z'},
+ {'created_at':'2015-08-12T00:00:00.000Z'},
+ {'created_at':'2015-08-13T00:00:00.000Z'},
+ {'created_at':'2015-08-14T00:00:00.000Z'},
+ {'created_at':'2015-08-15T00:00:00.000Z'},
+ {'created_at':'2015-08-16T00:00:00.000Z'},
+ {'created_at':'2015-08-17T00:00:00.000Z'},
+ {'created_at':'2015-08-18T00:00:00.000Z'},
+ {'created_at':'2015-08-19T00:00:00.000Z'},
+ {'created_at':'2015-08-20T00:00:00.000Z'},
+ {'created_at':'2015-08-21T00:00:00.000Z'},
+ {'created_at':'2015-08-22T00:00:00.000Z'},
+ {'created_at':'2015-08-23T00:00:00.000Z'},
+ {'created_at':'2015-08-24T00:00:00.000Z'},
+ {'created_at':'2015-08-25T00:00:00.000Z'},
+ {'created_at':'2015-08-26T00:00:00.000Z'},
+ {'created_at':'2015-08-27T00:00:00.000Z'},
+ {'created_at':'2015-08-28T00:00:00.000Z'},
+ {'created_at':'2015-08-29T00:00:00.000Z'},
+ {'created_at':'2015-08-30T00:00:00.000Z'},
+ {'created_at':'2015-08-31T00:00:00.000Z'},
+ {'created_at':'2015-09-01T00:00:00.000Z'},
+ {'created_at':'2015-09-02T00:00:00.000Z'},
+ {'created_at':'2015-09-03T00:00:00.000Z'},
+ {'created_at':'2015-09-04T00:00:00.000Z'},
+ {'created_at':'2015-09-05T00:00:00.000Z'},
+ {'created_at':'2015-09-06T00:00:00.000Z'},
+ {'created_at':'2015-09-07T00:00:00.000Z'}
+ ],
+ '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
+ {'created_at':'2015-08-08T00:00:00.000Z'},
+ {'created_at':'2015-08-09T00:00:00.000Z'},
+ {'created_at':'2015-08-10T00:00:00.000Z'},
+ {'created_at':'2015-08-11T00:00:00.000Z'},
+ {'created_at':'2015-08-12T00:00:00.000Z'},
+ {'created_at':'2015-08-13T00:00:00.000Z'},
+ {'created_at':'2015-08-14T00:00:00.000Z'},
+ {'created_at':'2015-08-15T00:00:00.000Z'},
+ {'created_at':'2015-08-16T00:00:00.000Z'},
+ {'created_at':'2015-08-17T00:00:00.000Z'},
+ {'created_at':'2015-08-18T00:00:00.000Z'},
+ {'created_at':'2015-08-19T00:00:00.000Z'},
+ {'created_at':'2015-08-20T00:00:00.000Z'},
+ {'created_at':'2015-08-21T00:00:00.000Z'},
+ {'created_at':'2015-08-22T00:00:00.000Z'},
+ {'created_at':'2015-08-23T00:00:00.000Z'},
+ {'created_at':'2015-08-24T00:00:00.000Z'},
+ {'created_at':'2015-08-25T00:00:00.000Z'},
+ {'created_at':'2015-08-26T00:00:00.000Z'},
+ {'created_at':'2015-08-27T00:00:00.000Z'},
+ {'created_at':'2015-08-28T00:00:00.000Z'},
+ {'created_at':'2015-08-29T00:00:00.000Z'},
+ {'created_at':'2015-08-30T00:00:00.000Z'},
+ {'created_at':'2015-08-31T00:00:00.000Z'},
+ {'created_at':'2015-09-01T00:00:00.000Z'},
+ {'created_at':'2015-09-02T00:00:00.000Z'},
+ {'created_at':'2015-09-03T00:00:00.000Z'},
+ {'created_at':'2015-09-04T00:00:00.000Z'},
+ {'created_at':'2015-09-05T00:00:00.000Z'},
+ {'created_at':'2015-09-06T00:00:00.000Z'},
+ {'created_at':'2015-09-07T00:00:00.000Z'}
+ ],
+ '/api/v1/devicestatus.json&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-08T23:59:59.999Z?find[openaps][$exists]=true&count=1000': [
+ {
+ 'openaps': {
+ 'suggested': {
+ 'temp': 'absolute',
+ 'bg': 67,
+ 'tick': '+6',
+ 'eventualBG': 145,
+ 'snoozeBG': 145,
+ 'reason': 'BG 67<74.5, delta 6>0; no high-temp to cancel',
+ 'timestamp': '2015-08-31T00:00:00.000Z'
+ }
+ },
+ 'created_at': '2015-08-31T00:00:00.000Z'
+ }
+ ],
+ '/api/v1/devicestatus.json&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z?find[openaps][$exists]=true&count=1000': [
{
'openaps': {
'suggested': {