2016-08-07 22:09:59 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const miscsUtils = {
|
2016-10-02 12:19:02 +02:00
|
|
|
dateIsValid
|
2016-08-07 22:09:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------- Export functions --------------------
|
|
|
|
|
2016-12-30 11:45:00 +01:00
|
|
|
function dateIsValid (dateString, interval) {
|
2016-08-07 22:09:59 +02:00
|
|
|
const dateToCheck = new Date(dateString)
|
|
|
|
const now = new Date()
|
|
|
|
|
|
|
|
// Check if the interval is more than 2 minutes
|
2016-12-30 11:45:00 +01:00
|
|
|
if (!interval) interval = 120000
|
|
|
|
|
|
|
|
if (now - dateToCheck > interval) return false
|
2016-08-07 22:09:59 +02:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = miscsUtils
|