isSameWeek.d.mts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { LocalizedOptions, WeekOptions } from "./types.js";
  2. /**
  3. * The {@link isSameWeek} function options.
  4. */
  5. export interface IsSameWeekOptions
  6. extends WeekOptions,
  7. LocalizedOptions<"options"> {}
  8. /**
  9. * @name isSameWeek
  10. * @category Week Helpers
  11. * @summary Are the given dates in the same week (and month and year)?
  12. *
  13. * @description
  14. * Are the given dates in the same week (and month and year)?
  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 dateLeft - The first date to check
  19. * @param dateRight - The second date to check
  20. * @param options - An object with options
  21. *
  22. * @returns The dates are in the same week (and month and year)
  23. *
  24. * @example
  25. * // Are 31 August 2014 and 4 September 2014 in the same week?
  26. * const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4))
  27. * //=> true
  28. *
  29. * @example
  30. * // If week starts with Monday,
  31. * // are 31 August 2014 and 4 September 2014 in the same week?
  32. * const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4), {
  33. * weekStartsOn: 1
  34. * })
  35. * //=> false
  36. *
  37. * @example
  38. * // Are 1 January 2014 and 1 January 2015 in the same week?
  39. * const result = isSameWeek(new Date(2014, 0, 1), new Date(2015, 0, 1))
  40. * //=> false
  41. */
  42. export declare function isSameWeek<DateType extends Date>(
  43. dateLeft: DateType | number | string,
  44. dateRight: DateType | number | string,
  45. options?: IsSameWeekOptions,
  46. ): boolean;