addHours.cjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. exports.addHours = addHours;
  3. var _index = require("./addMilliseconds.cjs");
  4. var _index2 = require("./constants.cjs");
  5. /**
  6. * The {@link addHours} function options.
  7. */
  8. /**
  9. * @name addHours
  10. * @category Hour Helpers
  11. * @summary Add the specified number of hours to the given date.
  12. *
  13. * @description
  14. * Add the specified number of hours to the given date.
  15. *
  16. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  17. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  18. *
  19. * @param date - The date to be changed
  20. * @param amount - The amount of hours to be added
  21. * @param options - An object with options
  22. *
  23. * @returns The new date with the hours added
  24. *
  25. * @example
  26. * // Add 2 hours to 10 July 2014 23:00:00:
  27. * const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
  28. * //=> Fri Jul 11 2014 01:00:00
  29. */
  30. function addHours(date, amount, options) {
  31. return (0, _index.addMilliseconds)(
  32. date,
  33. amount * _index2.millisecondsInHour,
  34. options,
  35. );
  36. }