index.js 644 B

12345678910111213141516171819202122232425
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Day Helpers
  4. * @summary Return the start of a day for the given date.
  5. *
  6. * @description
  7. * Return the start of a day 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 start of a day
  12. *
  13. * @example
  14. * // The start of a day for 2 September 2014 11:55:00:
  15. * var result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
  16. * //=> Tue Sep 02 2014 00:00:00
  17. */
  18. function startOfDay (dirtyDate) {
  19. var date = parse(dirtyDate)
  20. date.setHours(0, 0, 0, 0)
  21. return date
  22. }
  23. module.exports = startOfDay