isSameWeek.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { LocalizedOptions, WeekOptions } from "./types.js";
  2. import type { ContextOptions, DateArg } from "./types.js";
  3. /**
  4. * The {@link isSameWeek} function options.
  5. */
  6. export interface IsSameWeekOptions
  7. extends WeekOptions,
  8. LocalizedOptions<"options">,
  9. ContextOptions<Date> {}
  10. /**
  11. * @name isSameWeek
  12. * @category Week Helpers
  13. * @summary Are the given dates in the same week (and month and year)?
  14. *
  15. * @description
  16. * Are the given dates in the same week (and month and year)?
  17. *
  18. * @param laterDate - The first date to check
  19. * @param earlierDate - 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(
  43. laterDate: DateArg<Date> & {},
  44. earlierDate: DateArg<Date> & {},
  45. options?: IsSameWeekOptions,
  46. ): boolean;