isSameYear.cjs 914 B

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. exports.isSameYear = isSameYear;
  3. var _index = require("./_lib/normalizeDates.cjs");
  4. /**
  5. * The {@link isSameYear} function options.
  6. */
  7. /**
  8. * @name isSameYear
  9. * @category Year Helpers
  10. * @summary Are the given dates in the same year?
  11. *
  12. * @description
  13. * Are the given dates in the same year?
  14. *
  15. * @param laterDate - The first date to check
  16. * @param earlierDate - The second date to check
  17. * @param options - An object with options
  18. *
  19. * @returns The dates are in the same year
  20. *
  21. * @example
  22. * // Are 2 September 2014 and 25 September 2014 in the same year?
  23. * const result = isSameYear(new Date(2014, 8, 2), new Date(2014, 8, 25))
  24. * //=> true
  25. */
  26. function isSameYear(laterDate, earlierDate, options) {
  27. const [laterDate_, earlierDate_] = (0, _index.normalizeDates)(
  28. options?.in,
  29. laterDate,
  30. earlierDate,
  31. );
  32. return laterDate_.getFullYear() === earlierDate_.getFullYear();
  33. }