index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import isSameMonth from "../isSameMonth/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  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. * > ⚠️ Please note that this function is not present in the FP submodule as
  13. * > it uses `Date.now()` internally hence impure and can't be safely curried.
  14. *
  15. * ### v2.0.0 breaking changes:
  16. *
  17. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  18. *
  19. * @param {Date|Number} date - the date to check
  20. * @returns {Boolean} the date is in this month
  21. * @throws {TypeError} 1 argument required
  22. *
  23. * @example
  24. * // If today is 25 September 2014, is 15 September 2014 in this month?
  25. * var result = isThisMonth(new Date(2014, 8, 15))
  26. * //=> true
  27. */
  28. export default function isThisMonth(dirtyDate) {
  29. requiredArgs(1, arguments);
  30. return isSameMonth(Date.now(), dirtyDate);
  31. }