Both dates are normalised to local midnight before subtraction. This avoids errors from daylight-saving time changes and time zone shifts - only the calendar date matters, not the time of day. The total day count uses simple millisecond subtraction divided by 86,400,000 (ms per day), then rounded. This works correctly across DST boundaries because both dates are normalised first.
Working day count walks day-by-day from start to end, incrementing only when the day-of-week is Monday through Friday. Weekend count is the remainder. Public holidays are NOT subtracted because holiday calendars differ by state (Maharashtra has different holidays from Tamil Nadu), by religion, and by organisation policy (some companies observe second Saturdays as off, some don't). If you need precise net working days, manually subtract your specific holiday count.
Inclusive vs exclusive: in inclusive mode, both the start and end dates are counted. So 'from 1 Jan to 5 Jan inclusive' = 5 days. In exclusive (gap) mode, the result is 4 days. Use inclusive for rental/lease durations (5 days of rent), exam countdowns (5 days to study including today), and any 'days from-to' specification. Use exclusive for project elapsed time, age-style calculations, and 'X days between dates' phrasings.