specberus
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -184,2 +184,3 @@ | ||
, 'echidna.editor-ids.no-editor-id': 'Editor IDs must be set for each editor, in the <code>data-editor-id</code> attribute.' | ||
, 'echidna.todays-date.date-not-detected': 'The publication date of this document could not be detected.' | ||
, 'echidna.todays-date.wrong-date': 'The publication date of this document must be set to today.' | ||
@@ -186,0 +187,0 @@ } |
@@ -11,3 +11,3 @@ 'use strict'; | ||
if (/\d+/.test(strId)) return parseInt(strId, 10); | ||
}).toArray(); | ||
}).get(); | ||
@@ -14,0 +14,0 @@ sr.metadata('editorIDs', editorIDs); |
@@ -6,5 +6,17 @@ 'use strict'; | ||
exports.check = function (sr, done) { | ||
function getDate(date) { return date.setHours(0, 0, 0, 0); } | ||
/** | ||
* Get the timestamp of a day, regardless the time of the day. | ||
* This function creates a new `Date` to avoid modifying the original one. | ||
* | ||
* @param {Date} date - The date to extract the day, month and year from | ||
* @returns {number} number of milliseconds between 1 January 1970 and `date` | ||
*/ | ||
function getDateTime(date) { | ||
return new Date(date.getTime()).setHours(0, 0, 0, 0); | ||
} | ||
if (getDate(sr.getDocumentDate()) !== getDate(new Date())) { | ||
if (!(sr.getDocumentDate() instanceof Date)) { | ||
sr.error(exports.name, 'date-not-detected'); | ||
} | ||
else if (getDateTime(sr.getDocumentDate()) !== getDateTime(new Date())) { | ||
sr.error(exports.name, 'wrong-date'); | ||
@@ -11,0 +23,0 @@ } |
{ | ||
"name": "specberus", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "lib/validator", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2620808
25051