UNPKG

570 BJavaScriptView Raw
1import { toDate } from "./toDate.js";
2
3/**
4 * @name isFuture
5 * @category Common Helpers
6 * @summary Is the given date in the future?
7 * @pure false
8 *
9 * @description
10 * Is the given date in the future?
11 *
12 * @param date - The date to check
13 *
14 * @returns The date is in the future
15 *
16 * @example
17 * // If today is 6 October 2014, is 31 December 2014 in the future?
18 * const result = isFuture(new Date(2014, 11, 31))
19 * //=> true
20 */
21export function isFuture(date) {
22 return +toDate(date) > Date.now();
23}
24
25// Fallback for modularized imports:
26export default isFuture;