isThisYear.js 857 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. exports.isThisYear = isThisYear;
  3. var _index = require("./constructNow.js");
  4. var _index2 = require("./isSameYear.js");
  5. /**
  6. * @name isThisYear
  7. * @category Year Helpers
  8. * @summary Is the given date in the same year as the current date?
  9. * @pure false
  10. *
  11. * @description
  12. * Is the given date in the same year as the current date?
  13. *
  14. * @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).
  15. *
  16. * @param date - The date to check
  17. *
  18. * @returns The date is in this year
  19. *
  20. * @example
  21. * // If today is 25 September 2014, is 2 July 2014 in this year?
  22. * const result = isThisYear(new Date(2014, 6, 2))
  23. * //=> true
  24. */
  25. function isThisYear(date) {
  26. return (0, _index2.isSameYear)(date, (0, _index.constructNow)(date));
  27. }