@hestia-earth/schema-validation 30.7.2 → 30.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = exports.validate = exports.keyword = exports.isValidDate = void 0;
|
|
4
|
+
var formatDate = function (date) { return new Date("".concat(new Date(date).toJSON().substring(0, 10), "T12:00:00.000Z")); };
|
|
4
5
|
/**
|
|
5
6
|
* JavaScript does a lenient parsing of dates, so even `2000-30-30` will return a date.
|
|
6
7
|
* This makes sure the parse date is the date as the given date. *
|
|
@@ -14,7 +15,7 @@ var isValidDateRange = function (value) {
|
|
|
14
15
|
var month = values[1] || 1;
|
|
15
16
|
var day = values[2] || 1;
|
|
16
17
|
var date = new Date(year, month - 1, day, 12); // Months are 0-indexed
|
|
17
|
-
return (date <= new Date() && // date cannot be in the future
|
|
18
|
+
return (formatDate(date) <= formatDate(new Date()) && // date cannot be in the future
|
|
18
19
|
date.getFullYear() === year &&
|
|
19
20
|
date.getMonth() === month - 1 && // Months are 0-indexed
|
|
20
21
|
date.getDate() === day);
|