Date range overlap
A booking from the 1st to the 3rd is three days here, not two. Whole-day ranges are inclusive of both ends, which is what people mean by a date range. Timestamp ranges are usually half-open — start included, end excluded — and mixing the two conventions is where double-booking bugs come from.
Works out whether two date ranges overlap and by how many days, counting both ends inclusively. If they do not overlap, it gives the gap between them.
How to use the date range overlap
The convention is the thing to be clear about. Whole-day ranges are inclusive of both ends: 1 June to 3 June is three days, because all three days are in it. Timestamp ranges are almost always half-open — the start included, the end excluded — because that lets consecutive ranges meet without overlapping. Both are correct for their kind of value, and mixing them is where off-by-one double-bookings come from.
The overlap itself is a two-line calculation once stated properly: the overlap runs from the later of the two starts to the earlier of the two ends, and exists only if that start is not after that end. It is worth knowing because it is far easier than the case analysis people usually write — checking whether A starts inside B, or B inside A, or one contains the other, is four branches for something that needs one comparison.
Two ranges that touch — one ending on the 5th and the next starting on the 5th — overlap by one day under the inclusive convention. If they are meant to be back to back, the second should start on the 6th.
Questions
Yes. 1 June to 3 June is three days. That is what people mean by a whole-day range.