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