isThisMonth.mjs 890 B

123456789101112131415161718192021222324252627282930
  1. import { constructNow } from "./constructNow.mjs";
  2. import { isSameMonth } from "./isSameMonth.mjs";
  3. /**
  4. * @name isThisMonth
  5. * @category Month Helpers
  6. * @summary Is the given date in the same month as the current date?
  7. * @pure false
  8. *
  9. * @description
  10. * Is the given date in the same month as the current date?
  11. *
  12. * @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).
  13. *
  14. * @param date - The date to check
  15. *
  16. * @returns The date is in this month
  17. *
  18. * @example
  19. * // If today is 25 September 2014, is 15 September 2014 in this month?
  20. * const result = isThisMonth(new Date(2014, 8, 15))
  21. * //=> true
  22. */
  23. export function isThisMonth(date) {
  24. return isSameMonth(date, constructNow(date));
  25. }
  26. // Fallback for modularized imports:
  27. export default isThisMonth;