From 81648d685954a53173e80c2f14e3ce466b6d5714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levent=20Sencer=20=C5=9Eahin?= Date: Thu, 9 Jun 2022 07:17:39 +0300 Subject: [PATCH] Bug fixed to start date for intervals two dates option. --- nodes/inject.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nodes/inject.js b/nodes/inject.js index edf4766..796b789 100644 --- a/nodes/inject.js +++ b/nodes/inject.js @@ -100,20 +100,23 @@ module.exports = function(RED) { let crontime = handleCrontabWithCronti(this.crontiMethod, ...JSON.parse(this.crontiArgs)) this.cronjob = scheduleTask(crontime, () => { if(this.crontiMethod === "onIntervalTime") { + let startDate = new Date(JSON.parse(this.crontiArgs)[0]) let endDate = new Date(JSON.parse(this.crontiArgs)[1]) if(new Date() >= endDate) { this.cronjob.stop(); delete this.cronjob; return + } else if(new Date <= startDate) { + return } } node.emit("input", {}) }); - let endText = "" + let dateText = "" if(this.crontiMethod === "onIntervalTime") { - endText = "End:" + new Date(JSON.parse(this.crontiArgs)[1]).toISOString() + dateText = "ST:" + new Date(JSON.parse(this.crontiArgs)[0]).toISOString() + " | ET:" + new Date(JSON.parse(this.crontiArgs)[1]).toISOString() } - this.status({fill:"green",shape:"dot",text:crontime+" "+endText}); + this.status({fill:"green",shape:"dot",text:crontime+" | "+dateText}); } };