index.js 668 B

12345678910111213141516171819202122232425
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Second Helpers
  4. * @summary Return the end of a second for the given date.
  5. *
  6. * @description
  7. * Return the end of a second for the given date.
  8. * The result will be in the local timezone.
  9. *
  10. * @param {Date|String|Number} date - the original date
  11. * @returns {Date} the end of a second
  12. *
  13. * @example
  14. * // The end of a second for 1 December 2014 22:15:45.400:
  15. * var result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))
  16. * //=> Mon Dec 01 2014 22:15:45.999
  17. */
  18. function endOfSecond (dirtyDate) {
  19. var date = parse(dirtyDate)
  20. date.setMilliseconds(999)
  21. return date
  22. }
  23. module.exports = endOfSecond