Home Manual Reference Source Test Repository

lib/filter/future-date.js

  1. /**
  2. * Future date filter. Checks if a file's date occurs in the future.
  3. * @param {File} file File we're checking.
  4. * @param {Object} filterConfig Filter config object.
  5. * @return {boolean} If the File's date is in the future
  6. */
  7. export default function futureDatesFilter(file, filterConfig = {}) {
  8. const dateKey = filterConfig.key || 'date';
  9. const fileDate = new Date(file.data[dateKey]).getTime();
  10.  
  11. // If the date is in the future we have a positive number.
  12. return fileDate - Date.now() > 0;
  13. }