eachWeekendOfYear.cjs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. exports.eachWeekendOfYear = eachWeekendOfYear;
  3. var _index = require("./eachWeekendOfInterval.cjs");
  4. var _index2 = require("./endOfYear.cjs");
  5. var _index3 = require("./startOfYear.cjs");
  6. /**
  7. * The {@link eachWeekendOfYear} function options.
  8. */
  9. /**
  10. * @name eachWeekendOfYear
  11. * @category Year Helpers
  12. * @summary List all the Saturdays and Sundays in the year.
  13. *
  14. * @description
  15. * Get all the Saturdays and Sundays in the year.
  16. *
  17. * @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).
  18. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  19. *
  20. * @param date - The given year
  21. * @param options - An object with options
  22. *
  23. * @returns An array containing all the Saturdays and Sundays
  24. *
  25. * @example
  26. * // Lists all Saturdays and Sundays in the year
  27. * const result = eachWeekendOfYear(new Date(2020, 1, 1))
  28. * //=> [
  29. * // Sat Jan 03 2020 00:00:00,
  30. * // Sun Jan 04 2020 00:00:00,
  31. * // ...
  32. * // Sun Dec 27 2020 00:00:00
  33. * // ]
  34. * ]
  35. */
  36. function eachWeekendOfYear(date, options) {
  37. const start = (0, _index3.startOfYear)(date, options);
  38. const end = (0, _index2.endOfYear)(date, options);
  39. return (0, _index.eachWeekendOfInterval)({ start, end }, options);
  40. }