From 89e8708e763bd7ac1ab70b04c6318146c664a34d Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Mon, 11 Jul 2016 10:19:40 +0100 Subject: [PATCH] Date change now works first time for changing a single day. --- src/main/webdemo/js/app.js | 4 +++- src/main/webdemo/js/services/NodeApi.js | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/webdemo/js/app.js b/src/main/webdemo/js/app.js index 74152df6e1..e716480816 100644 --- a/src/main/webdemo/js/app.js +++ b/src/main/webdemo/js/app.js @@ -2,7 +2,9 @@ function formatDateForNode(date) { // Produces yyyy-dd-mm. JS is missing proper date formatting libs - return date.toISOString().substring(0, 10); + let day = ("0" + (date.getDate())).slice(-2); + let month = ("0" + (date.getMonth() + 1)).slice(-2); + return `${date.getFullYear()}-${month}-${day}`; } function formatDateForAngular(dateStr) { diff --git a/src/main/webdemo/js/services/NodeApi.js b/src/main/webdemo/js/services/NodeApi.js index ee4335fd94..a11de4a2ce 100644 --- a/src/main/webdemo/js/services/NodeApi.js +++ b/src/main/webdemo/js/services/NodeApi.js @@ -45,8 +45,7 @@ define(['angular', 'lodash'], (angular, _) => { break; case "day": - // +2 because date is 0 based in JS dates but 1 based in the API - newDate.setDate(date.getDate() + 2); + newDate.setDate(date.getDate() + 1); break; }