Skip to content

Commit deceef3

Browse files
Merge pull request #76 from WMEValidator/a-fix-past2
Fix $isInThePast time (again)
2 parents bc3b6ed + 8820a6a commit deceef3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/validate.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,16 @@ function F_VALIDATE(disabledHL) {
363363
this.$toDate = (timeFrame.getEndDate() || "");
364364
/** @type {string} */
365365
this.$toTime = (timeFrame.getToTime() || "");
366+
367+
/*
368+
* To avoid any issues with time zones, report expired
369+
* restrictions 1-2 days after.
370+
*/
371+
var past = new Date();
372+
past.setDate(past.getDate() - 2); /* 2..days().ago() */
366373
/** @type {boolean} */
367-
this.$isInThePast = new Date(this.$toDate +
368-
" " + this.$toTime) < new Date();
374+
this.$isInThePast = new Date(this.$toDate + " " +
375+
this.$toTime) < past;
369376

370377
Object.defineProperties(this, {
371378
_to: { enumerable: false },

0 commit comments

Comments
 (0)