UNPKG

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