index.js 551 B

12345678910111213141516171819202122
  1. var startOfDay = require('../start_of_day/index.js')
  2. /**
  3. * @category Day Helpers
  4. * @summary Is the given date today?
  5. *
  6. * @description
  7. * Is the given date today?
  8. *
  9. * @param {Date|String|Number} date - the date to check
  10. * @returns {Boolean} the date is today
  11. *
  12. * @example
  13. * // If today is 6 October 2014, is 6 October 14:00:00 today?
  14. * var result = isToday(new Date(2014, 9, 6, 14, 0))
  15. * //=> true
  16. */
  17. function isToday (dirtyDate) {
  18. return startOfDay(dirtyDate).getTime() === startOfDay(new Date()).getTime()
  19. }
  20. module.exports = isToday