getOverlappingDaysInIntervals.d.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { Interval } from "./types.js";
  2. /**
  3. * @name getOverlappingDaysInIntervals
  4. * @category Interval Helpers
  5. * @summary Get the number of days that overlap in two time intervals
  6. *
  7. * @description
  8. * Get the number of days that overlap in two time intervals. It uses the time
  9. * between dates to calculate the number of days, rounding it up to include
  10. * partial days.
  11. *
  12. * Two equal 0-length intervals will result in 0. Two equal 1ms intervals will
  13. * result in 1.
  14. *
  15. * @param intervalLeft - The first interval to compare.
  16. * @param intervalRight - The second interval to compare.
  17. * @param options - An object with options
  18. *
  19. * @returns The number of days that overlap in two time intervals
  20. *
  21. * @example
  22. * // For overlapping time intervals adds 1 for each started overlapping day:
  23. * getOverlappingDaysInIntervals(
  24. * { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) },
  25. * { start: new Date(2014, 0, 17), end: new Date(2014, 0, 21) }
  26. * )
  27. * //=> 3
  28. *
  29. * @example
  30. * // For non-overlapping time intervals returns 0:
  31. * getOverlappingDaysInIntervals(
  32. * { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) },
  33. * { start: new Date(2014, 0, 21), end: new Date(2014, 0, 22) }
  34. * )
  35. * //=> 0
  36. */
  37. export declare function getOverlappingDaysInIntervals(
  38. intervalLeft: Interval,
  39. intervalRight: Interval,
  40. ): number;