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