index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = startOfSecond;
  7. var _index = _interopRequireDefault(require("../toDate/index.js"));
  8. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  9. /**
  10. * @name startOfSecond
  11. * @category Second Helpers
  12. * @summary Return the start of a second for the given date.
  13. *
  14. * @description
  15. * Return the start of a second for the given date.
  16. * The result will be in the local timezone.
  17. *
  18. * @param {Date|Number} date - the original date
  19. * @returns {Date} the start of a second
  20. * @throws {TypeError} 1 argument required
  21. *
  22. * @example
  23. * // The start of a second for 1 December 2014 22:15:45.400:
  24. * const result = startOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))
  25. * //=> Mon Dec 01 2014 22:15:45.000
  26. */
  27. function startOfSecond(dirtyDate) {
  28. (0, _index2.default)(1, arguments);
  29. var date = (0, _index.default)(dirtyDate);
  30. date.setMilliseconds(0);
  31. return date;
  32. }
  33. module.exports = exports.default;