Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

32 linhas
1.2 KiB

  1. import toInteger from '../_lib/toInteger/index.js';
  2. import addMilliseconds from '../addMilliseconds/index.js';
  3. import requiredArgs from '../_lib/requiredArgs/index.js';
  4. var MILLISECONDS_IN_MINUTE = 60000;
  5. /**
  6. * @name addMinutes
  7. * @category Minute Helpers
  8. * @summary Add the specified number of minutes to the given date.
  9. *
  10. * @description
  11. * Add the specified number of minutes to the given date.
  12. *
  13. * ### v2.0.0 breaking changes:
  14. *
  15. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  16. *
  17. * @param {Date|Number} date - the date to be changed
  18. * @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`.
  19. * @returns {Date} the new date with the minutes added
  20. * @throws {TypeError} 2 arguments required
  21. *
  22. * @example
  23. * // Add 30 minutes to 10 July 2014 12:00:00:
  24. * var result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
  25. * //=> Thu Jul 10 2014 12:30:00
  26. */
  27. export default function addMinutes(dirtyDate, dirtyAmount) {
  28. requiredArgs(2, arguments);
  29. var amount = toInteger(dirtyAmount);
  30. return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE);
  31. }