index.js 779 B

1234567891011121314151617181920212223242526
  1. import toDate from "../toDate/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name endOfHour
  5. * @category Hour Helpers
  6. * @summary Return the end of an hour for the given date.
  7. *
  8. * @description
  9. * Return the end of an hour for the given date.
  10. * The result will be in the local timezone.
  11. *
  12. * @param {Date|Number} date - the original date
  13. * @returns {Date} the end of an hour
  14. * @throws {TypeError} 1 argument required
  15. *
  16. * @example
  17. * // The end of an hour for 2 September 2014 11:55:00:
  18. * const result = endOfHour(new Date(2014, 8, 2, 11, 55))
  19. * //=> Tue Sep 02 2014 11:59:59.999
  20. */
  21. export default function endOfHour(dirtyDate) {
  22. requiredArgs(1, arguments);
  23. var date = toDate(dirtyDate);
  24. date.setMinutes(59, 59, 999);
  25. return date;
  26. }