aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/tests/utils/miscs.js
blob: c4b661496a8c5bf3aa63833ea6f90156b301b2ae (plain) (tree)
1
2
3
4
5
6
7
8
9


                    
             



                                                               
                                             



                                                 


                                                






                                                                              
'use strict'

const miscsUtils = {
  dateIsValid
}

// ---------------------- Export functions --------------------

function dateIsValid (dateString, interval) {
  const dateToCheck = new Date(dateString)
  const now = new Date()

  // Check if the interval is more than 2 minutes
  if (!interval) interval = 120000

  if (now - dateToCheck > interval) return false

  return true
}

// ---------------------------------------------------------------------------

module.exports = miscsUtils