eachWeekendOfYear.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. exports.eachWeekendOfYear = eachWeekendOfYear;
  3. var _index = require("./eachWeekendOfInterval.js");
  4. var _index2 = require("./endOfYear.js");
  5. var _index3 = require("./startOfYear.js");
  6. /**
  7. * @name eachWeekendOfYear
  8. * @category Year Helpers
  9. * @summary List all the Saturdays and Sundays in the year.
  10. *
  11. * @description
  12. * Get all the Saturdays and Sundays in the year.
  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 given year
  17. *
  18. * @returns An array containing all the Saturdays and Sundays
  19. *
  20. * @example
  21. * // Lists all Saturdays and Sundays in the year
  22. * const result = eachWeekendOfYear(new Date(2020, 1, 1))
  23. * //=> [
  24. * // Sat Jan 03 2020 00:00:00,
  25. * // Sun Jan 04 2020 00:00:00,
  26. * // ...
  27. * // Sun Dec 27 2020 00:00:00
  28. * // ]
  29. * ]
  30. */
  31. function eachWeekendOfYear(date) {
  32. const start = (0, _index3.startOfYear)(date);
  33. const end = (0, _index2.endOfYear)(date);
  34. return (0, _index.eachWeekendOfInterval)({ start, end });
  35. }