index.js 641 B

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