Hacker News new | ask | show | jobs
by travisjungroth 2919 days ago
The number of options here is small enough (three) you should memorize it.

Subtract the start and stop. If the start and stop are both excluded, subtract 1. If one of them is included, make no change. If both are included, add 1.

Excluded start and stops happen when you have external boundaries. Like, your last day on the old project was the 10th, and your first day on the new one is the 15th. You had no project for 15-10-1=4 days.

One included happens when you're measuring between numbers. If you start working at 2 and finish at 8, you worked 8-2=6 hours.

Double inclusion counts when you have internal boundaries, or are counting how many things are "touched". If you work on something from the 11th to the 15th, you worked on it 15-11+1=5 days. (Also, your example.)

Stop position - start position + (number of included positions - 2) = total