UNPKG

925 BJavaScriptView Raw
1import { constructFrom } from "./constructFrom.js";
2import { constructNow } from "./constructNow.js";
3import { isSameMonth } from "./isSameMonth.js";
4
5/**
6 * The {@link isThisMonth} function options.
7 */
8
9/**
10 * @name isThisMonth
11 * @category Month Helpers
12 * @summary Is the given date in the same month as the current date?
13 * @pure false
14 *
15 * @description
16 * Is the given date in the same month as the current date?
17 *
18 * @param date - The date to check
19 * @param options - An object with options
20 *
21 * @returns The date is in this month
22 *
23 * @example
24 * // If today is 25 September 2014, is 15 September 2014 in this month?
25 * const result = isThisMonth(new Date(2014, 8, 15))
26 * //=> true
27 */
28export function isThisMonth(date, options) {
29 return isSameMonth(
30 constructFrom(options?.in || date, date),
31 constructNow(options?.in || date),
32 );
33}
34
35// Fallback for modularized imports:
36export default isThisMonth;