getOverlappingDaysInIntervals
返回两个时间间隔之间的重叠天数。
javascript
import { getOverlappingDaysInIntervals } from "date-fns";
// 示例时间间隔
const interval1 = { start: new Date(2024, 0, 1), end: new Date(2024, 0, 10) };
const interval2 = { start: new Date(2024, 0, 5), end: new Date(2024, 0, 15) };
// 返回两个时间间隔之间的重叠天数
const overlappingDays = getOverlappingDaysInIntervals(interval1, interval2);
console.log("两个时间间隔之间的重叠天数:", overlappingDays);
// 两个时间间隔之间的重叠天数:6