index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = setSeconds;
  7. var _index = _interopRequireDefault(require("../_lib/toInteger/index.js"));
  8. var _index2 = _interopRequireDefault(require("../toDate/index.js"));
  9. var _index3 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  10. /**
  11. * @name setSeconds
  12. * @category Second Helpers
  13. * @summary Set the seconds to the given date.
  14. *
  15. * @description
  16. * Set the seconds to the given date.
  17. *
  18. * @param {Date|Number} date - the date to be changed
  19. * @param {Number} seconds - the seconds of the new date
  20. * @returns {Date} the new date with the seconds set
  21. * @throws {TypeError} 2 arguments required
  22. *
  23. * @example
  24. * // Set 45 seconds to 1 September 2014 11:30:40:
  25. * const result = setSeconds(new Date(2014, 8, 1, 11, 30, 40), 45)
  26. * //=> Mon Sep 01 2014 11:30:45
  27. */
  28. function setSeconds(dirtyDate, dirtySeconds) {
  29. (0, _index3.default)(2, arguments);
  30. var date = (0, _index2.default)(dirtyDate);
  31. var seconds = (0, _index.default)(dirtySeconds);
  32. date.setSeconds(seconds);
  33. return date;
  34. }
  35. module.exports = exports.default;