index.js 916 B

123456789101112131415161718192021222324252627282930
  1. var startOfMinute = require('../start_of_minute/index.js')
  2. /**
  3. * @category Minute Helpers
  4. * @summary Are the given dates in the same minute?
  5. *
  6. * @description
  7. * Are the given dates in the same minute?
  8. *
  9. * @param {Date|String|Number} dateLeft - the first date to check
  10. * @param {Date|String|Number} dateRight - the second date to check
  11. * @returns {Boolean} the dates are in the same minute
  12. *
  13. * @example
  14. * // Are 4 September 2014 06:30:00 and 4 September 2014 06:30:15
  15. * // in the same minute?
  16. * var result = isSameMinute(
  17. * new Date(2014, 8, 4, 6, 30),
  18. * new Date(2014, 8, 4, 6, 30, 15)
  19. * )
  20. * //=> true
  21. */
  22. function isSameMinute (dirtyDateLeft, dirtyDateRight) {
  23. var dateLeftStartOfMinute = startOfMinute(dirtyDateLeft)
  24. var dateRightStartOfMinute = startOfMinute(dirtyDateRight)
  25. return dateLeftStartOfMinute.getTime() === dateRightStartOfMinute.getTime()
  26. }
  27. module.exports = isSameMinute