UNPKG

896 BJavaScriptView Raw
1"use strict";
2exports.subMinutes = subMinutes;
3var _index = require("./addMinutes.js");
4
5/**
6 * @name subMinutes
7 * @category Minute Helpers
8 * @summary Subtract the specified number of minutes from the given date.
9 *
10 * @description
11 * Subtract the specified number of minutes from the given date.
12 *
13 * @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).
14 *
15 * @param date - The date to be changed
16 * @param amount - The amount of minutes to be subtracted.
17 *
18 * @returns The new date with the minutes subtracted
19 *
20 * @example
21 * // Subtract 30 minutes from 10 July 2014 12:00:00:
22 * const result = subMinutes(new Date(2014, 6, 10, 12, 0), 30)
23 * //=> Thu Jul 10 2014 11:30:00
24 */
25function subMinutes(date, amount) {
26 return (0, _index.addMinutes)(date, -amount);
27}