isThisWeek.d.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import type { LocalizedOptions, WeekOptions } from "./types.js";
  2. /**
  3. * The {@link isThisWeek} function options.
  4. */
  5. export interface IsThisWeekOptions
  6. extends WeekOptions,
  7. LocalizedOptions<"options"> {}
  8. /**
  9. * @name isThisWeek
  10. * @category Week Helpers
  11. * @summary Is the given date in the same week as the current date?
  12. * @pure false
  13. *
  14. * @description
  15. * Is the given date in the same week as the current date?
  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 date to check
  20. * @param options - The object with options
  21. *
  22. * @returns The date is in this week
  23. *
  24. * @example
  25. * // If today is 25 September 2014, is 21 September 2014 in this week?
  26. * const result = isThisWeek(new Date(2014, 8, 21))
  27. * //=> true
  28. *
  29. * @example
  30. * // If today is 25 September 2014 and week starts with Monday
  31. * // is 21 September 2014 in this week?
  32. * const result = isThisWeek(new Date(2014, 8, 21), { weekStartsOn: 1 })
  33. * //=> false
  34. */
  35. export declare function isThisWeek<DateType extends Date>(
  36. date: DateType | number | string,
  37. options?: IsThisWeekOptions,
  38. ): boolean;