getWeeksInMonth.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import type { LocalizedOptions, WeekOptions } from "./types.js";
  2. /**
  3. * The {@link getWeeksInMonth} function options.
  4. */
  5. export interface GetWeeksInMonthOptions
  6. extends LocalizedOptions<"options">,
  7. WeekOptions {}
  8. /**
  9. * @name getWeeksInMonth
  10. * @category Week Helpers
  11. * @summary Get the number of calendar weeks a month spans.
  12. *
  13. * @description
  14. * Get the number of calendar weeks the month in the given date spans.
  15. *
  16. * @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).
  17. *
  18. * @param date - The given date
  19. * @param options - An object with options.
  20. *
  21. * @returns The number of calendar weeks
  22. *
  23. * @example
  24. * // How many calendar weeks does February 2015 span?
  25. * const result = getWeeksInMonth(new Date(2015, 1, 8))
  26. * //=> 4
  27. *
  28. * @example
  29. * // If the week starts on Monday,
  30. * // how many calendar weeks does July 2017 span?
  31. * const result = getWeeksInMonth(new Date(2017, 6, 5), { weekStartsOn: 1 })
  32. * //=> 6
  33. */
  34. export declare function getWeeksInMonth<DateType extends Date>(
  35. date: DateType | number | string,
  36. options?: GetWeeksInMonthOptions,
  37. ): number;