1 | ;
|
2 | exports.isBefore = isBefore;
|
3 | var _index = require("./toDate.js");
|
4 |
|
5 | /**
|
6 | * @name isBefore
|
7 | * @category Common Helpers
|
8 | * @summary Is the first date before the second one?
|
9 | *
|
10 | * @description
|
11 | * Is the first date before the second one?
|
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 that should be before the other one to return true
|
16 | * @param dateToCompare - The date to compare with
|
17 | *
|
18 | * @returns The first date is before the second date
|
19 | *
|
20 | * @example
|
21 | * // Is 10 July 1989 before 11 February 1987?
|
22 | * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
|
23 | * //=> false
|
24 | */
|
25 | function isBefore(date, dateToCompare) {
|
26 | const _date = (0, _index.toDate)(date);
|
27 | const _dateToCompare = (0, _index.toDate)(dateToCompare);
|
28 | return +_date < +_dateToCompare;
|
29 | }
|