UNPKG

930 BJavaScriptView Raw
1"use strict";
2exports.isThisSecond = isThisSecond;
3var _index = require("./constructNow.js");
4var _index2 = require("./isSameSecond.js");
5
6/**
7 * @name isThisSecond
8 * @category Second Helpers
9 * @summary Is the given date in the same second as the current date?
10 * @pure false
11 *
12 * @description
13 * Is the given date in the same second as the current date?
14 *
15 * @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).
16 *
17 * @param date - The date to check
18 *
19 * @returns The date is in this second
20 *
21 * @example
22 * // If now is 25 September 2014 18:30:15.500,
23 * // is 25 September 2014 18:30:15.000 in this second?
24 * const result = isThisSecond(new Date(2014, 8, 25, 18, 30, 15))
25 * //=> true
26 */
27function isThisSecond(date) {
28 return (0, _index2.isSameSecond)(date, (0, _index.constructNow)(date));
29}