From 8820a6a86bc8b07135fdad54d6034272de97c9db Mon Sep 17 00:00:00 2001 From: Andriy Berestovskyy Date: Sun, 7 Oct 2018 13:56:08 +0200 Subject: [PATCH] Fix $isInThePast time To avoid issues with time zones and when there is no toTime set --- src/validate.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/validate.js b/src/validate.js index a743237..7b9c613 100644 --- a/src/validate.js +++ b/src/validate.js @@ -363,9 +363,16 @@ function F_VALIDATE(disabledHL) { this.$toDate = (timeFrame.getEndDate() || ""); /** @type {string} */ this.$toTime = (timeFrame.getToTime() || ""); + + /* + * To avoid any issues with time zones, report expired + * restrictions 1-2 days after. + */ + var past = new Date(); + past.setDate(past.getDate() - 2); /* 2..days().ago() */ /** @type {boolean} */ - this.$isInThePast = new Date(this.$toDate + - " " + this.$toTime) < new Date(); + this.$isInThePast = new Date(this.$toDate + " " + + this.$toTime) < past; Object.defineProperties(this, { _to: { enumerable: false },