index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = addMinutes;
  6. var _index = _interopRequireDefault(require("../_lib/toInteger/index.js"));
  7. var _index2 = _interopRequireDefault(require("../addMilliseconds/index.js"));
  8. var _index3 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. var MILLISECONDS_IN_MINUTE = 60000;
  11. /**
  12. * @name addMinutes
  13. * @category Minute Helpers
  14. * @summary Add the specified number of minutes to the given date.
  15. *
  16. * @description
  17. * Add the specified number of minutes to the given date.
  18. *
  19. * ### v2.0.0 breaking changes:
  20. *
  21. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  22. *
  23. * @param {Date|Number} date - the date to be changed
  24. * @param {Number} amount - the amount of minutes to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
  25. * @returns {Date} the new date with the minutes added
  26. * @throws {TypeError} 2 arguments required
  27. *
  28. * @example
  29. * // Add 30 minutes to 10 July 2014 12:00:00:
  30. * const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
  31. * //=> Thu Jul 10 2014 12:30:00
  32. */
  33. function addMinutes(dirtyDate, dirtyAmount) {
  34. (0, _index3.default)(2, arguments);
  35. var amount = (0, _index.default)(dirtyAmount);
  36. return (0, _index2.default)(dirtyDate, amount * MILLISECONDS_IN_MINUTE);
  37. }
  38. module.exports = exports.default;