index.js 928 B

123456789101112131415161718192021222324252627
  1. import isSameQuarter from "../isSameQuarter/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name isThisQuarter
  5. * @category Quarter Helpers
  6. * @summary Is the given date in the same quarter as the current date?
  7. * @pure false
  8. *
  9. * @description
  10. * Is the given date in the same quarter 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. * @param {Date|Number} date - the date to check
  16. * @returns {Boolean} the date is in this quarter
  17. * @throws {TypeError} 1 argument required
  18. *
  19. * @example
  20. * // If today is 25 September 2014, is 2 July 2014 in this quarter?
  21. * const result = isThisQuarter(new Date(2014, 6, 2))
  22. * //=> true
  23. */
  24. export default function isThisQuarter(dirtyDate) {
  25. requiredArgs(1, arguments);
  26. return isSameQuarter(Date.now(), dirtyDate);
  27. }