index.js 800 B

1234567891011121314151617181920212223242526
  1. import toDate from "../toDate/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name endOfMinute
  5. * @category Minute Helpers
  6. * @summary Return the end of a minute for the given date.
  7. *
  8. * @description
  9. * Return the end of a minute 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 a minute
  14. * @throws {TypeError} 1 argument required
  15. *
  16. * @example
  17. * // The end of a minute for 1 December 2014 22:15:45.400:
  18. * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400))
  19. * //=> Mon Dec 01 2014 22:15:59.999
  20. */
  21. export default function endOfMinute(dirtyDate) {
  22. requiredArgs(1, arguments);
  23. var date = toDate(dirtyDate);
  24. date.setSeconds(59, 999);
  25. return date;
  26. }