lastDayOfWeek.d.mts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import type { LocalizedOptions, WeekOptions } from "./types.js";
  2. /**
  3. * The {@link lastDayOfWeek} function options.
  4. */
  5. export interface LastDayOfWeekOptions
  6. extends LocalizedOptions<"options">,
  7. WeekOptions {}
  8. /**
  9. * @name lastDayOfWeek
  10. * @category Week Helpers
  11. * @summary Return the last day of a week for the given date.
  12. *
  13. * @description
  14. * Return the last day of a week for the given date.
  15. * The result will be in the local timezone.
  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. *
  19. * @param date - The original date
  20. * @param options - An object with options
  21. *
  22. * @returns The last day of a week
  23. *
  24. * @example
  25. * // The last day of a week for 2 September 2014 11:55:00:
  26. * const result = lastDayOfWeek(new Date(2014, 8, 2, 11, 55, 0))
  27. * //=> Sat Sep 06 2014 00:00:00
  28. *
  29. * @example
  30. * // If the week starts on Monday, the last day of the week for 2 September 2014 11:55:00:
  31. * const result = lastDayOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
  32. * //=> Sun Sep 07 2014 00:00:00
  33. */
  34. export declare function lastDayOfWeek<DateType extends Date>(
  35. date: DateType | number | string,
  36. options?: LastDayOfWeekOptions,
  37. ): DateType;