1
Count the minutes from shift start to midnight. For a 10:00 PM start, that's 2 hours.
2
Count the minutes from midnight to shift end. For a 6:00 AM end, that's 6 more hours.
3
Add the two segments: 2h + 6h = 8h, correctly spanning the boundary — never a negative number.
4
If a same-day shift is entered (end time later than start time on the same day), no midnight crossing happens and the tool does plain subtraction instead — no segment split is shown.